diff options
Diffstat (limited to 'Build/source/texk/bibtexu')
-rw-r--r-- | Build/source/texk/bibtexu/ChangeLog | 9 | ||||
-rw-r--r-- | Build/source/texk/bibtexu/bibtex-1.c | 54 | ||||
-rw-r--r-- | Build/source/texk/bibtexu/bibtex-2.c | 37 | ||||
-rw-r--r-- | Build/source/texk/bibtexu/bibtex-3.c | 14 | ||||
-rw-r--r-- | Build/source/texk/bibtexu/datatype.h | 2 | ||||
-rw-r--r-- | Build/source/texk/bibtexu/gblprocs.h | 2 | ||||
-rw-r--r-- | Build/source/texk/bibtexu/gblvars.h | 6 | ||||
-rw-r--r-- | Build/source/texk/bibtexu/utils.c | 30 |
8 files changed, 45 insertions, 109 deletions
diff --git a/Build/source/texk/bibtexu/ChangeLog b/Build/source/texk/bibtexu/ChangeLog index b004e57bc90..ea50ae8ef08 100644 --- a/Build/source/texk/bibtexu/ChangeLog +++ b/Build/source/texk/bibtexu/ChangeLog @@ -1,3 +1,12 @@ +2010-03-18 Peter Breitenlohner <peb@mppmu.mpg.de> + + Dynamic allocation of name_of_file strings. No padding. + * bibtex-1.c (add_area): Not used and removed. + * bibtex-2.c (file_nm_size_overflow): Not used and removed. + * bibtex-3.c (s_bst_area, s_bib_area): Removed. + * gblvars.h (bib_area_string, bst_area_string): Removed. + * utils.c (open_ip_file, open_op_file): Adapted. + 2010-03-17 Peter Breitenlohner <peb@mppmu.mpg.de> * bibtex-1.c (check_cite_overflow): Reallocate cite_info, diff --git a/Build/source/texk/bibtexu/bibtex-1.c b/Build/source/texk/bibtexu/bibtex-1.c index 07c0391f2bd..02ef546fc63 100644 --- a/Build/source/texk/bibtexu/bibtex-1.c +++ b/Build/source/texk/bibtexu/bibtex-1.c @@ -162,36 +162,9 @@ Include the ICU heads. 23/sep/2009 * of the filename. It also sets the global variable |name_length| to the * appropriate value. * - * NOTE: because C arrays start at index 0, not 1, the subscripts of array - * |name_of_file| are generally 1 less than those in the WEB source. + * REMOVED: |add_area|. ***************************************************************************/ -void add_area (StrNumber_T area) -BEGIN - PoolPointer_T p_ptr; - if ((name_length + LENGTH (area)) > FILE_NAME_SIZE) - BEGIN - PRINT ("File="); - PRINT_POOL_STR (area); - PRINT2 ("%s,", name_of_file); - file_nm_size_overflow (); - END - name_ptr = name_length - 1; - while (name_ptr >= 0) - BEGIN - name_of_file[name_ptr + LENGTH (area)] = name_of_file[name_ptr]; - DECR (name_ptr); - END - name_ptr = 0; - p_ptr = str_start[area]; - while (p_ptr < str_start[area + 1]) - BEGIN - name_of_file[name_ptr] = CHR (str_pool[p_ptr]); - INCR (name_ptr); - INCR (p_ptr); - END - name_length = name_length + LENGTH (area); -END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 61 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -261,13 +234,6 @@ void add_extension (StrNumber_T ext) BEGIN PoolPointer_T p_ptr; - if ((name_length + LENGTH (ext)) > FILE_NAME_SIZE) - BEGIN - PRINT2 ("File=%s, extension=", name_of_file); - PRINT_POOL_STR (ext); - PRINT_LN (","); - file_nm_size_overflow (); - END name_ptr = name_length; p_ptr = str_start[ext]; while (p_ptr < str_start[ext + 1]) @@ -277,12 +243,7 @@ BEGIN INCR (p_ptr); END name_length = name_length + LENGTH (ext); - name_ptr = name_length; - while (name_ptr < FILE_NAME_SIZE) - BEGIN - name_of_file[name_ptr] = ' '; - INCR (name_ptr); - END + name_of_file[name_length] = 0; END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 60 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -526,8 +487,6 @@ BEGIN add_extension (s_bib_extension); if ( ! a_open_in (&CUR_BIB_FILE, BIB_FILE_SEARCH_PATH)) BEGIN - add_area (s_bib_area); - if ( ! a_open_in (&CUR_BIB_FILE, BIB_FILE_SEARCH_PATH)) BEGIN OPEN_BIBDATA_AUX_ERR ("I couldn't open database file "); perror ("\nReason"); @@ -605,8 +564,6 @@ BEGIN add_extension (s_bst_extension); if ( ! a_open_in (&bst_file, BST_FILE_SEARCH_PATH)) BEGIN - add_area (s_bst_area); - if ( ! a_open_in (&bst_file, BST_FILE_SEARCH_PATH)) BEGIN PRINT ("I couldn't open style file "); print_bst_name (); @@ -984,12 +941,7 @@ BEGIN ***************************************************************************/ BEGIN start_name (CUR_AUX_STR); - name_ptr = name_length; - while (name_ptr < FILE_NAME_SIZE) - BEGIN - name_of_file[name_ptr] = ' '; - INCR (name_ptr); - END + name_of_file[name_length] = 0; if ( ! a_open_in (&CUR_AUX_FILE, AUX_FILE_SEARCH_PATH)) BEGIN PRINT ("I couldn't open auxiliary file "); diff --git a/Build/source/texk/bibtexu/bibtex-2.c b/Build/source/texk/bibtexu/bibtex-2.c index d6e25a10b6d..713a1a40c08 100644 --- a/Build/source/texk/bibtexu/bibtex-2.c +++ b/Build/source/texk/bibtexu/bibtex-2.c @@ -30,7 +30,6 @@ ** ** execute_fn ** figure_out_the_formatted_name -** file_nm_size_overflow ** find_cite_locs_for_this_cite_ke ** get_aux_command_and_process ** get_bib_command_or_entry_and_pr @@ -1173,11 +1172,10 @@ END * WEB section number: 59 * ~~~~~~~~~~~~~~~~~~~ * Yet another complaint-before-quiting. + * + * REMOVED: |file_nm_size_overflow|. ***************************************************************************/ -void file_nm_size_overflow (void) -BEGIN - BIBTEX_OVERFLOW ("file name size ", FILE_NAME_SIZE); -END + /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 59 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -2017,9 +2015,26 @@ BEGIN * already stopped after issuing a "Usage" error. ***************************************************************************/ BEGIN - (void) strncpy (name_of_file, Str_auxfile, FILE_NAME_SIZE); - name_of_file[FILE_NAME_SIZE] = '\0'; - aux_name_length = strlen (name_of_file); + /* + ** Leave room for the extension and the null byte at the end. + */ + aux_name_length = strlen (Str_auxfile); + name_of_file = (unsigned char *) mymalloc (aux_name_length + 5, "name_of_file"); + strncpy ((char *) name_of_file, Str_auxfile, aux_name_length); + + /* + ** If the auxilliary file was specified with the ".aux" part already + ** appended, we strip it off here. + */ + if (aux_name_length > 4) { + if ((Str_auxfile[aux_name_length-4] == '.') + && ((Str_auxfile[aux_name_length-3] == 'a') || (Str_auxfile[aux_name_length-3] == 'A')) + && ((Str_auxfile[aux_name_length-2] == 'u') || (Str_auxfile[aux_name_length-2] == 'U')) + && ((Str_auxfile[aux_name_length-1] == 'x') || (Str_auxfile[aux_name_length-1] == 'X'))) + aux_name_length -= 4; + } + + name_of_file[aux_name_length] = 0; END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 102 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ @@ -2033,12 +2048,6 @@ BEGIN * store the name strings we'll need later. ***************************************************************************/ BEGIN - if (((aux_name_length + LENGTH (s_aux_extension)) > FILE_NAME_SIZE) - || ((aux_name_length + LENGTH (s_bib_extension)) > FILE_NAME_SIZE) - || ((aux_name_length + LENGTH (s_bbl_extension)) > FILE_NAME_SIZE)) - BEGIN - SAM_YOU_MADE_THE_FILE_NAME_TOO; - END /*************************************************************************** * WEB section number: 106 diff --git a/Build/source/texk/bibtexu/bibtex-3.c b/Build/source/texk/bibtexu/bibtex-3.c index bc02cf14b6b..1d8125354f2 100644 --- a/Build/source/texk/bibtexu/bibtex-3.c +++ b/Build/source/texk/bibtexu/bibtex-3.c @@ -185,10 +185,6 @@ BEGIN s_bst_extension = hash_text[pre_def_loc]; pre_define (".bib ", 4, FILE_EXT_ILK); s_bib_extension = hash_text[pre_def_loc]; - pre_define (" ", 0, FILE_AREA_ILK); - s_bst_area = hash_text[pre_def_loc]; - pre_define (" ", 0, FILE_AREA_ILK); - s_bib_area = hash_text[pre_def_loc]; /*************************************************************************** * WEB section number: 79 @@ -2361,13 +2357,8 @@ void start_name (StrNumber_T file_name) BEGIN PoolPointer_T p_ptr; - if (LENGTH (file_name) > FILE_NAME_SIZE) - BEGIN - PRINT ("File="); - PRINT_POOL_STR (file_name); - PRINT_LN (","); - file_nm_size_overflow (); - END + free (name_of_file); + name_of_file = (unsigned char *) mymalloc (LENGTH (file_name) + 5, "name_of_file"); name_ptr = 0; p_ptr = str_start[file_name]; while (p_ptr < str_start[file_name + 1]) @@ -2377,6 +2368,7 @@ BEGIN INCR (p_ptr); END name_length = LENGTH (file_name); + name_of_file[name_length] = 0; END /*^^^^^^^^^^^^^^^^^^^^^^^^^^ END OF SECTION 58 ^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ diff --git a/Build/source/texk/bibtexu/datatype.h b/Build/source/texk/bibtexu/datatype.h index 986d27d1c13..3fe9d9b4a0d 100644 --- a/Build/source/texk/bibtexu/datatype.h +++ b/Build/source/texk/bibtexu/datatype.h @@ -167,7 +167,7 @@ typedef Integer8_T LexType_T; typedef Integer16_T LitStkLoc_T; typedef UChar_T PdsLen_T; typedef Integer8_T PdsLoc_T; -typedef const UChar_T PdsType_T[FILE_NAME_SIZE + 1]; +typedef const UChar_T *PdsType_T; typedef Unsigned16_T PoolPointer_T; typedef Integer8_T StkType_T; typedef Integer16_T StrEntLoc_T; diff --git a/Build/source/texk/bibtexu/gblprocs.h b/Build/source/texk/bibtexu/gblprocs.h index e2fe236cdf8..3429598a977 100644 --- a/Build/source/texk/bibtexu/gblprocs.h +++ b/Build/source/texk/bibtexu/gblprocs.h @@ -108,7 +108,6 @@ Boolean_T a_open_in (AlphaFile_T *file_pointer, //Boolean_T u_file_open_in (UFILE *u_file_pointer, Integer_T search_path); Boolean_T a_open_out (AlphaFile_T *file_pointer); //Boolean_T u_file_open_out (UFILE *u_file_pointer); -void add_area (StrNumber_T area); void add_buf_pool (StrNumber_T pstr); void add_database_cite (CiteNumber_T *newcite); void add_extension (StrNumber_T ext); @@ -188,7 +187,6 @@ Boolean_T eoln (const AlphaFile_T file_pointer); void execute_fn (HashLoc_T exfnloc); void figure_out_the_formatted_name (void); -void file_nm_size_overflow (void); Boolean_T find_cite_locs_for_this_cite_ke (StrNumber_T citestr); void get_aux_command_and_process (void); diff --git a/Build/source/texk/bibtexu/gblvars.h b/Build/source/texk/bibtexu/gblvars.h index b56b60bc214..c6a3aae71ea 100644 --- a/Build/source/texk/bibtexu/gblvars.h +++ b/Build/source/texk/bibtexu/gblvars.h @@ -159,13 +159,11 @@ __EXTERN__ HashLoc_T b_write; __EXTERN__ Integer_T bad; __EXTERN__ AlphaFile_T bbl_file; __EXTERN__ Integer_T bbl_line_num; -__EXTERN__ PdsType_T bib_area_string; __EXTERN__ Integer_T bib_brace_level; __EXTERN__ Integer_T bib_line_num; __EXTERN__ BibNumber_T bib_ptr; __EXTERN__ Boolean_T bib_seen; __EXTERN__ Integer_T brace_level; -__EXTERN__ PdsType_T bst_area_string; __EXTERN__ LongJumpBuf_T Bst_Done_Flag; __EXTERN__ AlphaFile_T bst_file; __EXTERN__ Integer_T bst_line_num; @@ -289,9 +287,7 @@ __EXTERN__ ASCIICode_T right_str_delim; __EXTERN__ StrNumber_T s_aux_extension; __EXTERN__ StrNumber_T s_bbl_extension; -__EXTERN__ StrNumber_T s_bib_area; __EXTERN__ StrNumber_T s_bib_extension; -__EXTERN__ StrNumber_T s_bst_area; __EXTERN__ StrNumber_T s_bst_extension; __EXTERN__ StrNumber_T s_default; __EXTERN__ StrNumber_T s_l; @@ -360,7 +356,6 @@ __EXTERN__ IDType_T id_class[LAST_ASCII_CHAR + 1]; __EXTERN__ LexType_T lex_class[LAST_ASCII_CHAR + 1]; __EXTERN__ Integer_T lit_stack[LIT_STK_SIZE + 1]; __EXTERN__ StkType_T lit_stk_type[LIT_STK_SIZE + 1]; -__EXTERN__ unsigned char name_of_file[FILE_NAME_SIZE + 1]; __EXTERN__ unsigned char xchr[LAST_ASCII_CHAR + 1]; __EXTERN__ ASCIICode_T xord[LAST_TEXT_CHAR + 1]; @@ -410,6 +405,7 @@ __EXTERN__ StrIlk_T *hash_ilk; __EXTERN__ HashPointer_T *hash_next; __EXTERN__ StrNumber_T *hash_text; __EXTERN__ Integer_T *ilk_info; +__EXTERN__ unsigned char *name_of_file; __EXTERN__ ASCIICode_T *name_sep_char; __EXTERN__ BufPointer_T *name_tok; __EXTERN__ ASCIICode_T *out_buf; diff --git a/Build/source/texk/bibtexu/utils.c b/Build/source/texk/bibtexu/utils.c index f01d64b080a..452696b2bda 100644 --- a/Build/source/texk/bibtexu/utils.c +++ b/Build/source/texk/bibtexu/utils.c @@ -784,7 +784,7 @@ void *myrealloc (void *old_ptr, const unsigned long bytes_required, const char * */ FILE *open_ip_file (Integer_T search_path) { - char filename[FILE_NAME_SIZE + 1]; + const char *filename = (const char *) name_of_file; #ifdef KPATHSEA string full_filespec; #else @@ -793,9 +793,6 @@ FILE *open_ip_file (Integer_T search_path) FILE *fptr; int status; - (void) strncpy (filename, name_of_file, (size_t) name_length); - filename[name_length] = '\0'; - switch (search_path) { case AUX_FILE_SEARCH_PATH: #ifdef KPATHSEA @@ -886,12 +883,9 @@ not_ok: */ FILE *open_op_file (void) { - char tmp_file_name[FILE_NAME_SIZE + 1]; + const char *tmp_file_name = (const char *) name_of_file; FILE *fptr; - (void) strncpy (tmp_file_name, name_of_file, (size_t) name_length); - tmp_file_name[name_length] = '\0'; - debug_msg (DBG_IO, "open_op_file: trying to open `%s' ... ", tmp_file_name); @@ -963,7 +957,7 @@ FILE *open_op_file (void) */ void parse_cmd_line (int argc, char **argv) { - int c, l; + int c; int no_files; Flag_7bit = FALSE; @@ -1098,21 +1092,6 @@ Get the option, and change the flag. 23/sep/2009 } /* - ** If the auxilliary file was specified with the ".aux" part already - ** appended, we strip it off here. (It's a bit of a bodge, but it - ** minimises the changes necessary to the original BibTeX code.) - */ - l = strlen (Str_auxfile); - - if (l > 4) { - if ((Str_auxfile[l-4] == '.') - && ((Str_auxfile[l-3] == 'a') || (Str_auxfile[l-3] == 'A')) - && ((Str_auxfile[l-2] == 'u') || (Str_auxfile[l-2] == 'U')) - && ((Str_auxfile[l-1] == 'x') || (Str_auxfile[l-1] == 'X'))) - Str_auxfile[l-4] = '\0'; - } - - /* ** Check for contradictory options */ if (Flag_7bit && Flag_8bit) { @@ -1175,7 +1154,6 @@ void report_bibtex_capacity (void) LOG_CAPACITY (AUX_STACK_SIZE); LOG_CAPACITY (Buf_Size); LOG_CAPACITY (ENT_STR_SIZE); - LOG_CAPACITY (FILE_NAME_SIZE); LOG_CAPACITY (GLOB_STR_SIZE); LOG_CAPACITY (Hash_Prime); LOG_CAPACITY (Hash_Size); @@ -1737,6 +1715,8 @@ int c8read_csf (void) /* ** If the CS file name doesn't contain a '.', append ".csf". */ + free (name_of_file); + name_of_file = (unsigned char *) mymalloc (strlen (Str_csfile) + 5, "name_of_file"); strcpy (name_of_file, Str_csfile); if (strchr (name_of_file, '.') == NULL) |