apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: apr-iconv/util iconv.c
Date Fri, 26 Sep 2003 07:47:14 GMT
jerenkrantz    2003/09/26 00:47:14

  Modified:    .        CHANGES Makefile.in buildconf configure.in
               build    .cvsignore
               lib      .cvsignore Makefile.in
               util     iconv.c
  Added:       include  api_version.h
               lib      api_version.c
  Log:
  Forward port apr-iconv changes from API_0_9_BRANCH
  
  Add in api_version.{c|h} to allow iconv to have a version number, too.
  Take another pass at a build system and have it *really* use exports.
  
  Revision  Changes    Path
  1.9       +10 -0     apr-iconv/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr-iconv/CHANGES,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -u -r1.8 -r1.9
  --- CHANGES	24 Apr 2003 08:08:31 -0000	1.8
  +++ CHANGES	26 Sep 2003 07:47:13 -0000	1.9
  @@ -1,4 +1,14 @@
  +Changes with APR-ICONV 1.0
  +
  +Changes with APR-ICONV 0.9.5
  +
   Changes with APR-ICONV 0.9.4
  +
  +  *) Add -v option to iconv program. [Justin Erenkrantz]
  +
  +  *) Add api_version.h. [Justin Erenkrantz]
  +
  +  *) A fourth pass at a build system. [Justin Erenkrantz]
   
     *) A third pass at a build system. [Justin Erenkrantz]
   
  
  
  
  1.6       +13 -36    apr-iconv/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr-iconv/Makefile.in,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -u -r1.5 -r1.6
  --- Makefile.in	24 Apr 2003 08:08:31 -0000	1.5
  +++ Makefile.in	26 Sep 2003 07:47:13 -0000	1.6
  @@ -1,20 +1,19 @@
   #
   # Top-level Makefile for APRICONV
   #
  -abs_srcdir=@abs_srcdir@
  -abs_builddir=@abs_builddir@
  +abs_srcdir=@api_srcdir@
  +abs_builddir=@api_builddir@
   VPATH = @srcdir@
   
   # bring in rules.mk for standard functionality
   @INCLUDE_RULES@
   
  -SUBDIRS = lib ccs ces
  -CLEAN_SUBDIRS = . lib ccs ces
  +SUBDIRS = lib ccs ces util
  +CLEAN_SUBDIRS = . lib ccs ces util
   
  -TARGET_LIB = lib/libapriconv.la
  +TARGET_LIB = libapriconv.la
   
  -CLEAN_TARGETS = $(TARGET_EXPORTS)
  -DISTCLEAN_TARGETS = config.cache config.log config.status export_vars.sh
  +DISTCLEAN_TARGETS = config.cache config.log config.status
   EXTRACLEAN_TARGETS = configure libtool aclocal.m4
   
   ### install location
  @@ -26,26 +25,17 @@
   
   MKINSTALLDIRS=$(abs_srcdir)/build/mkdir.sh
   
  -delete-lib:
  -	@if test -f $(TARGET_LIB); then \
  -	    objects="`find $(SUBDIRS) -name '*.lo' -a -newer $(TARGET_LIB)`" ; \
  -	    if test -n "$$objects"; then \
  -		echo Found newer objects. Will relink $(TARGET_LIB). ; \
  -		echo $(RM) -f $(TARGET_LIB) ; \
  -		$(RM) -f $(TARGET_LIB) ; \
  -	    fi \
  -	fi
  -
  -install: $(TARGET_LIB)
  +install:
   	if [ ! -d $(includedir) ]; then \
   	    $(MKINSTALLDIRS) $(includedir); \
   	fi; \
  +	cp -p $(abs_srcdir)/include/*.h $(includedir); \
   	cp -p $(abs_srcdir)/lib/*.h $(includedir); \
   	cp -p $(abs_builddir)/lib/*.h $(includedir); \
   	if [ ! -d $(lib_prefix) ]; then \
   	    $(MKINSTALLDIRS) $(lib_prefix); \
  -	fi; \
  -	$(LIBTOOL) --mode=install cp $(TARGET_LIB) $(lib_prefix)
  +	fi;
  +	(cd lib; $(LIBTOOL) --mode=install cp $(TARGET_LIB) $(lib_prefix))
   	if [ ! -d $(libdir) ]; then \
   	    $(MKINSTALLDIRS) $(libdir); \
   	fi; \
  @@ -54,23 +44,10 @@
   	if [ ! -d $(exec_prefix) ]; then \
   	    $(MKINSTALLDIRS) $(exec_prefix); \
   	fi; \
  -	(cd util/.libs; $(LIBTOOL) --mode=install cp iconv $(exec_prefix))
  -
  -delete-exports:
  -	@if test -f $(TARGET_EXPORTS); then \
  -	    headers="`find lib/*.h -newer $(TARGET_EXPORTS)`" ; \
  -	    if test -n "$$headers"; then \
  -		echo Found newer headers. Will rebuild $(TARGET_EXPORTS). ; \
  -		echo $(RM) -f $(TARGET_EXPORTS) ; \
  -		$(RM) -f $(TARGET_EXPORTS) ; \
  -	    fi \
  -	fi
  -
  -$(TARGET_EXPORTS):
  -	$(AWK) -f @APR_SOURCE_DIR@/build/make_export.awk lib/*.h > $@ ;
  +	(cd util; $(LIBTOOL) --mode=install cp iconv $(exec_prefix))
   
   docs:
   	mkdir ./docs
  -	perl @APR_SOURCE_DIR@/build/scandoc.pl -i./build/default.pl -p./docs/ ./lib/*.h
  +	perl $(abs_srcdir)/build/scandoc.pl -i./build/default.pl -p./docs/ ./lib/*.h
   
  -.PHONY: delete-lib delete-exports
  +.PHONY: delete-lib
  
  
  
  1.3       +5 -2      apr-iconv/buildconf
  
  Index: buildconf
  ===================================================================
  RCS file: /home/cvs/apr-iconv/buildconf,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -u -r1.2 -r1.3
  --- buildconf	24 Apr 2003 08:08:31 -0000	1.2
  +++ buildconf	26 Sep 2003 07:47:13 -0000	1.3
  @@ -35,10 +35,13 @@
   
   # Remove some files, then copy them from apr source tree
   rm -f build/apr_common.m4 build/find_apr.m4 build/install.sh \
  -      build/config.guess build/config.sub build/mkdir.sh
  +      build/config.guess build/config.sub build/mkdir.sh \
  +      build/make_exports.awk build/make_var_export.awk
   cp $apr_src_dir/build/apr_common.m4 $apr_src_dir/build/find_apr.m4 \
      $apr_src_dir/build/install.sh $apr_src_dir/build/config.guess  \
  -   $apr_src_dir/build/config.sub $apr_src_dir/build/mkdir.sh build
  +   $apr_src_dir/build/config.sub $apr_src_dir/build/mkdir.sh \
  +   $apr_src_dir/build/make_exports.awk $apr_src_dir/build/make_var_export.awk \
  +   build
   
   # Remove aclocal.m4 as it'll break some builds...
   rm -rf aclocal.m4 autom4te*.cache
  
  
  
  1.8       +13 -15    apr-iconv/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apr-iconv/configure.in,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -u -r1.7 -r1.8
  --- configure.in	24 Apr 2003 08:08:31 -0000	1.7
  +++ configure.in	26 Sep 2003 07:47:13 -0000	1.8
  @@ -17,15 +17,13 @@
   AC_PROG_AWK
   
   dnl compute the top directory of the build
  -abs_srcdir=`(cd $srcdir && pwd)`
  -abs_builddir=`pwd`
  -top_builddir="$abs_builddir"
  -
  -AC_SUBST(abs_srcdir)
  -AC_SUBST(abs_builddir)
  -AC_SUBST(top_builddir)
  +# Absolute source/build directory
  +api_srcdir=`(cd $srcdir && pwd)`
  +api_builddir=`pwd`
  +AC_SUBST(api_srcdir)
  +AC_SUBST(api_builddir)
   
  -if test "$abs_builddir" != "$abs_srcdir"; then
  +if test "$api_builddir" != "$api_srcdir"; then
     USE_VPATH=1
   fi
   
  @@ -33,17 +31,17 @@
   API_FIND_APR
   
   dnl copy apr's rules.mk into our build directory.
  -if test ! -d $abs_builddir/build ; then
  -  mkdir $abs_builddir/build
  +if test ! -d $api_builddir/build ; then
  +  mkdir $api_builddir/build
   fi
  -cp $APR_BUILD_DIR/apr_rules.mk $abs_builddir/build/rules.mk
  +cp $APR_BUILD_DIR/apr_rules.mk $api_builddir/build/rules.mk
   
   dnl
   dnl set up the compilation flags and stuff
   dnl
  -API_INCLUDES="-I$abs_builddir/lib -I$abs_builddir/include"
  +API_INCLUDES="-I$api_builddir/lib -I$api_builddir/include"
   if test -n "$USE_VPATH"; then
  -  API_INCLUDES="$API_INCLUDES -I$abs_srcdir/lib -I$abs_srcdir/include"
  +  API_INCLUDES="$API_INCLUDES -I$api_srcdir/lib -I$api_srcdir/include"
   fi
   
   AC_SUBST(API_INCLUDES)
  @@ -61,10 +59,10 @@
   dnl
   case "$host_alias" in
   *bsdi*)
  -    INCLUDE_RULES=".include \"$abs_builddir/build/rules.mk\""
  +    INCLUDE_RULES=".include \"$api_builddir/build/rules.mk\""
       ;;
   *)
  -    INCLUDE_RULES="include $abs_builddir/build/rules.mk"
  +    INCLUDE_RULES="include $api_builddir/build/rules.mk"
       ;;
   esac
   AC_SUBST(INCLUDE_RULES)
  
  
  
  1.3       +2 -0      apr-iconv/build/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/apr-iconv/build/.cvsignore,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -u -r1.2 -r1.3
  --- .cvsignore	24 Apr 2003 08:08:31 -0000	1.2
  +++ .cvsignore	26 Sep 2003 07:47:13 -0000	1.3
  @@ -4,3 +4,5 @@
   find_apr.m4
   install.sh
   mkdir.sh
  +make_exports.awk
  +make_var_export.awk
  
  
  
  1.2       +144 -0    apr-iconv/include/api_version.h
  
  
  
  
  1.2       +1 -0      apr-iconv/lib/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/apr-iconv/lib/.cvsignore,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -u -r1.1 -r1.2
  --- .cvsignore	22 May 2001 13:45:35 -0000	1.1
  +++ .cvsignore	26 Sep 2003 07:47:13 -0000	1.2
  @@ -3,5 +3,6 @@
   *.lo
   *.slo
   apriconv.exports
  +exports.c
   apr_iconv_private.h.in
   apr_iconv_private.h
  
  
  
  1.4       +26 -1     apr-iconv/lib/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apr-iconv/lib/Makefile.in,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- Makefile.in	24 Apr 2003 08:08:32 -0000	1.3
  +++ Makefile.in	26 Sep 2003 07:47:13 -0000	1.4
  @@ -1,14 +1,26 @@
   # Generated automatically from Makefile.in by configure.
  +abs_srcdir=@api_srcdir@
  +abs_builddir=@api_builddir@
   VPATH = @srcdir@
   
  +prefix=@prefix@
  +exec_prefix=@exec_prefix@
  +libdir=@libdir@
  +
   INCLUDES = @API_INCLUDES@ @APR_INCLUDES@
   
   TARGET_LIB = libapriconv.la
   SUBDIRS = .
   
  +EXPORT_FILES = $(abs_srcdir)/include/*.h $(abs_srcdir)/lib/*.h
  +TARGET_EXPORTS = apriconv.exports
  +
  +CLEAN_TARGETS = exports.c
  +
   # May need to do something for apriconv.exports
   TARGETS = iconv_module.lo iconv.lo iconv_int.lo iconv_uc.lo \
  -	iconv_ces.lo iconv_ces_euc.lo iconv_ces_iso2022.lo $(TARGET_LIB)
  +	iconv_ces.lo iconv_ces_euc.lo iconv_ces_iso2022.lo api_version.lo \
  +	exports.lo $(TARGET_LIB)
   
   #OBJECTS=
   
  @@ -20,3 +32,16 @@
   	tmpcmd="$(LINK) @APR_LIB_TARGET@"; \
   	echo $$tmpcmd; \
   	$$tmpcmd && touch $@
  +
  +exports.c:
  +	$(AWK) -f $(abs_srcdir)/build/make_exports.awk $(EXPORT_FILES) > $@
  +
  +export_vars.h:
  +	$(AWK) -f $(abs_srcdir)/build/make_var_export.awk $(EXPORT_FILES) > $@
  +
  +$(TARGET_EXPORTS): exports.c export_vars.h
  +	@echo "#! lib@APR_LIBNAME@.so" > $@
  +	@echo "* This file was AUTOGENERATED at build time." >> $@
  +	@echo "* Please do not edit by hand." >> $@
  +	$(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$$/\1/'
>> $@
  +	$(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) export_vars.h | sed -e 's/^\#[^!]*//' | sed -e
'/^$$/d' >> $@
  
  
  
  1.2       +75 -0     apr-iconv/lib/api_version.c
  
  
  
  
  1.7       +46 -27    apr-iconv/util/iconv.c
  
  Index: iconv.c
  ===================================================================
  RCS file: /home/cvs/apr-iconv/util/iconv.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -u -r1.6 -r1.7
  --- iconv.c	28 May 2003 14:05:50 -0000	1.6
  +++ iconv.c	26 Sep 2003 07:47:14 -0000	1.7
  @@ -31,6 +31,9 @@
    */
   
   #include "apr.h"
  +#include "apr_getopt.h"
  +
  +#include "api_version.h"
   
   #include <stdarg.h>	/* va_end, va_list, va_start */
   #include <stdio.h>	/* FILE, fclose, ferror, fopen, fread, stdin,
  @@ -79,31 +82,55 @@
   }
   
   int
  -main(int argc, char * const *argv)
  +main(int argc, const char **argv)
   {
   	apr_iconv_t cd;
   	iconv_stream *is;
  -	char *from = NULL, *to = NULL, *input = NULL;
  -	int opt;
  +	const char *from = NULL, *to = NULL, *input = NULL;
  +	char opt;
   	apr_pool_t *ctx; 
   	apr_status_t status;
  +    apr_getopt_t *options;
  +    const char *opt_arg;
   
  -	while ((opt = getopt(argc, argv, "f:s:t:")) > 0) {
  -		switch (opt) {
  -		    case 'f':
  -			from = optarg;
  -			break;
  -		    case 't':
  -			to = optarg;
  -			break;
  -		    case 's':
  -			input = optarg;
  -			break;
  -		    default:
  -			fprintf(stderr, "Usage: iconv -f <name> -t <name> [-s <input>]\n");
  -			exit(3);
  -		}
  -	}
  +    /* Initialize APR */
  +    apr_initialize();
  +    atexit(closeapr);
  +    if (apr_pool_create(&ctx, NULL) != APR_SUCCESS) {
  +        fprintf(stderr, "Couldn't allocate context.\n");
  +        exit(-1);
  +    }
  +
  +    apr_getopt_init(&options, ctx, argc, argv);
  +
  +    status = apr_getopt(options, "f:s:t:v", &opt, &opt_arg);
  +
  +    while (status == APR_SUCCESS) {
  +        switch (opt) {
  +        case 'f':
  +            from = opt_arg;
  +            break;
  +        case 't':
  +            to = opt_arg;
  +            break;
  +        case 's':
  +            input = opt_arg;
  +            break;
  +        case 'v':
  +            fprintf(stderr, "APR-iconv version " API_VERSION_STRING "\n");
  +            exit(0);
  +        default:
  +            fprintf(stderr, "Usage: iconv -f <name> -t <name> [-s <input>]\n");
  +            exit(3);
  +        }
  +
  +        status = apr_getopt(options, "f:s:t:v",&opt, &opt_arg);
  +    }
  +
  +    if (status == APR_BADCH || status == APR_BADARG) {
  +        fprintf(stderr, "Usage: iconv -f <name> -t <name> [-s <input>]\n");
  +        exit(3);
  +    }
   	if (from == NULL) {
   		fprintf(stderr, "missing source charset (-f <name>)\n");
   		exit(4);
  @@ -111,14 +138,6 @@
   	if (to == NULL) {
   		fprintf(stderr, "missing destination charset (-t <name>)\n");
   		exit(5);
  -	}
  -
  -	/* Initialize APR */
  -	apr_initialize();
  -	atexit(closeapr);
  -	if (apr_pool_create(&ctx, NULL) != APR_SUCCESS) {
  -		fprintf(stderr, "Couldn't allocate context.\n");
  -		exit(-1);
   	}
   
   	/* Use it */
  
  
  

Mime
View raw message