Diff for /embedaddon/libiconv/lib/genaliases.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 22:57:48 version 1.1.1.2, 2021/03/17 13:38:46
Line 1 Line 1
/* Copyright (C) 1999-2001, 2003, 2005, 2008 Free Software Foundation, Inc./* Copyright (C) 1999-2001, 2003, 2005, 2008, 2012, 2017 Free Software Foundation, Inc.
    This file is part of the GNU LIBICONV Library.     This file is part of the GNU LIBICONV Library.
   
    The GNU LIBICONV Library is free software; you can redistribute it     The GNU LIBICONV Library is free software; you can redistribute it
Line 13 Line 13
   
    You should have received a copy of the GNU Library General Public     You should have received a copy of the GNU Library General Public
    License along with the GNU LIBICONV Library; see the file COPYING.LIB.     License along with the GNU LIBICONV Library; see the file COPYING.LIB.
   If not, write to the Free Software Foundation, Inc., 51 Franklin Street,   If not, see <https://www.gnu.org/licenses/>.  */
   Fifth Floor, Boston, MA 02110-1301, USA.  */ 
   
 /* Creates the aliases.gperf table. */  /* Creates the aliases.gperf table. */
   
Line 56  static void emit_encoding (FILE* out1, FILE* out2, con Line 55  static void emit_encoding (FILE* out1, FILE* out2, con
     emit_alias(out1, *names, c_name);      emit_alias(out1, *names, c_name);
 }  }
   
int main ()int main (int argc, char* argv[])
 {  {
  FILE* stdout2;  char* aliases_file_name;
   char* canonical_sh_file_name;
   char* canonical_local_sh_file_name;
   FILE* aliases_file;
   FILE* canonical_sh_file;
   
  printf("struct alias { int name; unsigned int encoding_index; };\n");  if (argc != 4) {
  printf("%%struct-type\n");    fprintf(stderr, "Usage: genaliases aliases.gperf canonical.sh canonical_local.sh\n");
  printf("%%language=ANSI-C\n");    exit(1);
  printf("%%define hash-function-name aliases_hash\n");  }
  printf("%%define lookup-function-name aliases_lookup\n"); 
  printf("%%7bit\n"); 
  printf("%%readonly-tables\n"); 
  printf("%%global-table\n"); 
  printf("%%define word-array-name aliases\n"); 
  printf("%%pic\n"); 
  printf("%%%%\n"); 
   
     aliases_file_name = argv[1];
     canonical_sh_file_name = argv[2];
     canonical_local_sh_file_name = argv[3];
   
     aliases_file = fopen(aliases_file_name, "w");
     if (aliases_file == NULL) {
       fprintf(stderr, "Could not open '%s' for writing\n", aliases_file_name);
       exit(1);
     }
   
     fprintf(aliases_file, "struct alias { int name; unsigned int encoding_index; };\n");
     fprintf(aliases_file, "%%struct-type\n");
     fprintf(aliases_file, "%%language=ANSI-C\n");
     fprintf(aliases_file, "%%define hash-function-name aliases_hash\n");
     fprintf(aliases_file, "%%define lookup-function-name aliases_lookup\n");
     fprintf(aliases_file, "%%7bit\n");
     fprintf(aliases_file, "%%readonly-tables\n");
     fprintf(aliases_file, "%%global-table\n");
     fprintf(aliases_file, "%%define word-array-name aliases\n");
     fprintf(aliases_file, "%%pic\n");
     fprintf(aliases_file, "%%%%\n");
   
 #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \  #define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \
   {                                                           \    {                                                           \
     static const char* const names[] = BRACIFY xxx_names;     \      static const char* const names[] = BRACIFY xxx_names;     \
    emit_encoding(stdout,stdout2,names,sizeof(names)/sizeof(names[0]),#xxx); \    emit_encoding(aliases_file,canonical_sh_file,names,sizeof(names)/sizeof(names[0]),#xxx); \
   }    }
 #define BRACIFY(...) { __VA_ARGS__ }  #define BRACIFY(...) { __VA_ARGS__ }
#define DEFALIAS(xxx_alias,xxx) emit_alias(stdout,xxx_alias,#xxx);#define DEFALIAS(xxx_alias,xxx) emit_alias(aliases_file,xxx_alias,#xxx);
   
  stdout2 = fdopen(3, "w");  canonical_sh_file = fopen(canonical_sh_file_name, "wb");
  if (stdout2 == NULL)  if (canonical_sh_file == NULL) {
     fprintf(stderr, "Could not open '%s' for writing\n", canonical_sh_file_name);
     exit(1);      exit(1);
     }
 #include "encodings.def"  #include "encodings.def"
  if (fclose(stdout2))  if (ferror(canonical_sh_file) || fclose(canonical_sh_file))
     exit(1);      exit(1);
   
  stdout2 = fdopen(4, "w");  canonical_sh_file = fopen(canonical_local_sh_file_name, "wb");
  if (stdout2 == NULL)  if (canonical_sh_file == NULL) {
     fprintf(stderr, "Could not open '%s' for writing\n", canonical_local_sh_file_name);
     exit(1);      exit(1);
     }
 #include "encodings_local.def"  #include "encodings_local.def"
  if (fclose(stdout2))  if (ferror(canonical_sh_file) || fclose(canonical_sh_file))
     exit(1);      exit(1);
   
 #undef DEFALIAS  #undef DEFALIAS
 #undef BRACIFY  #undef BRACIFY
 #undef DEFENCODING  #undef DEFENCODING
   
  if (ferror(stdout) || fclose(stdout))  if (ferror(aliases_file) || fclose(aliases_file))
     exit(1);      exit(1);
   exit(0);    exit(0);
 }  }

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>