[BACK]Return to gencat.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / gencat

Diff for /src/usr.bin/gencat/gencat.c between version 1.13 and 1.14

version 1.13, 2009/10/27 23:59:38 version 1.14, 2011/01/01 11:25:54
Line 314 
Line 314 
                 if (quote && *cptr == quote) {                  if (quote && *cptr == quote) {
                         char   *tmp;                          char   *tmp;
                         tmp = cptr + 1;                          tmp = cptr + 1;
   
                         if (*tmp && (!ISSPACE(*tmp) || *wskip(tmp))) {                          if (*tmp && (!ISSPACE(*tmp) || *wskip(tmp))) {
                                 warning(cptr, "unexpected quote character, ignoring");                                  warning(cptr, "unexpected quote character, ignoring");
                                 *tptr++ = *cptr++;                                  *tptr++ = *cptr++;
                         } else {                          } else {
                                 *cptr = '\0';                                  *cptr = '\0';
                         }                          }
                 } else                  } else if (*cptr == '\\') {
                         if (*cptr == '\\') {                          ++cptr;
                           switch (*cptr) {
                           case '\0':
                                   cptr = getline(fd);
                                   if (!cptr)
                                           error(NULL, "premature end of file");
                                   msglen += strlen(cptr);
                                   i = tptr - msg;
                                   msg = xrealloc(msg, msglen);
                                   tptr = msg + i;
                                   break;
                           case 'n':
                                   *tptr++ = '\n';
                                 ++cptr;                                  ++cptr;
                                 switch (*cptr) {                                  break;
                                 case '\0':                          case 't':
                                         cptr = getline(fd);                                  *tptr++ = '\t';
                                         if (!cptr)                                  ++cptr;
                                                 error(NULL, "premature end of file");                                  break;
                                         msglen += strlen(cptr);                          case 'v':
                                         i = tptr - msg;                                  *tptr++ = '\v';
                                         msg = xrealloc(msg, msglen);                                  ++cptr;
                                         tptr = msg + i;                                  break;
                                         break;                          case 'b':
                                 case 'n':                                  *tptr++ = '\b';
                                         *tptr++ = '\n';                                  ++cptr;
                                         ++cptr;                                  break;
                                         break;                          case 'r':
                                 case 't':                                  *tptr++ = '\r';
                                         *tptr++ = '\t';                                  ++cptr;
                                         ++cptr;                                  break;
                                         break;                          case 'f':
                                 case 'v':                                  *tptr++ = '\f';
                                         *tptr++ = '\v';                                  ++cptr;
                                         ++cptr;                                  break;
                                         break;                          case '\\':
                                 case 'b':                                  *tptr++ = '\\';
                                         *tptr++ = '\b';                                  ++cptr;
                                         ++cptr;                                  break;
                                         break;                          case '"':
                                 case 'r':                                  /* FALLTHROUGH */
                                         *tptr++ = '\r';                          case '\'':
                                         ++cptr;                                  /*
                                         break;                                   * While it isn't necessary to
                                 case 'f':                                   * escape ' and ", let's accept
                                         *tptr++ = '\f';                                   * them escaped and not complain.
                                         ++cptr;                                   * (XPG4 states that '\' should be
                                         break;                                   * ignored when not used in a
                                 case '\\':                                   * valid escape sequence)
                                         *tptr++ = '\\';                                   */
                                         ++cptr;                                  *tptr++ = '"';
                                         break;                                  ++cptr;
                                 case '"':                                  break;
                                         /* FALLTHROUGH */                          default:
                                 case '\'':                                  if (quote && *cptr == quote) {
                                         /*                                          *tptr++ = *cptr++;
                                          * While it isn't necessary to                                  } else if (isdigit((unsigned char) *cptr)) {
                                          * escape ' and ", let's accept                                          *tptr = 0;
                                          * them escaped and not complain.                                          for (i = 0; i < 3; ++i) {
                                          * (XPG4 states that '\' should be                                                  if (!isdigit((unsigned char) *cptr))
                                          * ignored when not used in a                                                          break;
                                          * valid escape sequence)                                                  if (*cptr > '7')
                                          */                                                          warning(cptr, "octal number greater than 7?!");
                                         *tptr++ = '"';                                                  *tptr *= 8;
                                         ++cptr;                                                  *tptr += (*cptr - '0');
                                         break;                                                  ++cptr;
                                 default:  
                                         if (quote && *cptr == quote) {  
                                                 *tptr++ = *cptr++;  
                                         } else if (isdigit((unsigned char) *cptr)) {  
                                                 *tptr = 0;  
                                                 for (i = 0; i < 3; ++i) {  
                                                         if (!isdigit((unsigned char) *cptr))  
                                                                 break;  
                                                         if (*cptr > '7')  
                                                                 warning(cptr, "octal number greater than 7?!");  
                                                         *tptr *= 8;  
                                                         *tptr += (*cptr - '0');  
                                                         ++cptr;  
                                                 }  
                                         } else {  
                                                 warning(cptr, "unrecognized escape sequence; ignoring esacpe character");  
                                         }                                          }
                                         break;                                  } else {
                                           warning(cptr, "unrecognized escape sequence; ignoring esacpe character");
                                 }                                  }
                         } else {                                  break;
                                 *tptr++ = *cptr++;  
                         }                          }
                   } else {
                           *tptr++ = *cptr++;
                   }
         }          }
         *tptr = '\0';          *tptr = '\0';
         return (msg);          return (msg);

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14