@@ -42,9 +42,12 @@ typedef off_t rt_off_t;
4242/* Information about current tag file */
4343struct sTagFile {
4444 /* has the file been opened and this structure initialized? */
45- short initialized ;
45+ unsigned char initialized ;
4646 /* format of tag file */
47- short format ;
47+ unsigned char format ;
48+ /* 1 "u-ctags" is set to !_TAG_OUTPUT_MODE pseudo tag
49+ * in the tags file. */
50+ unsigned char inputUCtagsMode ;
4851 /* how is the tag file sorted? */
4952 tagSortType sortMethod ;
5053 /* pointer to file structure */
@@ -519,26 +522,15 @@ static unsigned int countContinuousBackslashesBackward(const char *from,
519522 return counter ;
520523}
521524
522- static tagResult parseTagLine (tagFile * file , tagEntry * const entry , int * err )
525+ /* When unescaping, the input string becomes shorter.
526+ * e.g. \t occupies two bytes on the tag file.
527+ * It is converted to 0x9 and occupies one byte.
528+ * memmove called here for shortening the line
529+ * buffer. */
530+ static char * unescapeInPlace (char * q , char * * tab , size_t * p_len )
523531{
524- int i ;
525- char * p = file -> line .buffer ;
526- size_t p_len = strlen (p );
527- char * tab = strchr (p , TAB );
532+ char * p = q ;
528533
529- memset (entry , 0 , sizeof (* entry ));
530-
531- entry -> name = p ;
532- if (tab != NULL )
533- {
534- * tab = '\0' ;
535- }
536-
537- /* When unescaping, the input string becomes shorter.
538- * e.g. \t occupies two bytes on the tag file.
539- * It is converted to 0x9 and occupies one byte.
540- * memmove called here for shortening the line
541- * buffer. */
542534 while (* p != '\0' )
543535 {
544536 const char * next = p ;
@@ -547,21 +539,50 @@ static tagResult parseTagLine (tagFile *file, tagEntry *const entry, int *err)
547539
548540 * p = (char ) ch ;
549541 p ++ ;
550- p_len -= skip ;
542+ * p_len -= skip ;
551543 if (skip > 1 )
552544 {
553545 /* + 1 is for moving the area including the last '\0'. */
554- memmove (p , next , p_len + 1 );
555- if (tab )
556- tab -= skip - 1 ;
546+ memmove (p , next , * p_len + 1 );
547+ if (* tab )
548+ * tab -= skip - 1 ;
557549 }
558550 }
559551
552+ return p ;
553+ }
554+
555+ static tagResult parseTagLine (tagFile * file , tagEntry * const entry , int * err )
556+ {
557+ int i ;
558+ char * p = file -> line .buffer ;
559+ size_t p_len = strlen (p );
560+ char * tab = strchr (p , TAB );
561+
562+ memset (entry , 0 , sizeof (* entry ));
563+
564+ entry -> name = p ;
565+ if (tab != NULL )
566+ {
567+ * tab = '\0' ;
568+ }
569+
570+ p = unescapeInPlace (p , & tab , & p_len );
571+
560572 if (tab != NULL )
561573 {
562574 p = tab + 1 ;
563575 entry -> file = p ;
564576 tab = strchr (p , TAB );
577+ if (file -> inputUCtagsMode )
578+ {
579+ if (tab != NULL )
580+ {
581+ * tab = '\0' ;
582+ }
583+ p = unescapeInPlace (p , & tab , & p_len );
584+ }
585+
565586 if (tab != NULL )
566587 {
567588 int fieldsPresent ;
@@ -717,7 +738,7 @@ static tagResult readPseudoTags (tagFile *const file, tagFileInfo *const info)
717738 err = TagErrnoUnexpectedFormat ;
718739 break ;
719740 }
720- file -> format = (short ) m ;
741+ file -> format = (unsigned char ) m ;
721742 }
722743 else if (strcmp (key , "TAG_PROGRAM_AUTHOR" ) == 0 )
723744 {
@@ -755,6 +776,11 @@ static tagResult readPseudoTags (tagFile *const file, tagFileInfo *const info)
755776 break ;
756777 }
757778 }
779+ else if (strcmp (key , "TAG_OUTPUT_MODE" ) == 0 )
780+ {
781+ if (strcmp (value , "u-ctags" ) == 0 )
782+ file -> inputUCtagsMode = 1 ;
783+ }
758784
759785 info -> file .format = file -> format ;
760786 info -> file .sort = file -> sortMethod ;
0 commit comments