fix: last char in rpmrc w/o terminating newline lost (#4361).
prepare for handling \r in macro exapnsions. CVS patchset: 3230 CVS date: 1999/08/16 18:57:37
This commit is contained in:
parent
96114b6bf2
commit
06689265dd
2
CHANGES
2
CHANGES
|
@ -25,6 +25,8 @@
|
|||
- fix: don't remove file until last occurence in transaction (#4291).
|
||||
- resuscitate net shared paths (#4330).
|
||||
- fix: macro table cannot contain NULL pointers (#4263).
|
||||
- fix: last char in rpmrc w/o terminating newline lost (#4361).
|
||||
- prepare for handling \r in macro exapnsions.
|
||||
|
||||
3.0.1 -> 3.0.2
|
||||
- eliminate armv4 entries from rpmrc (Andrew E. Mileski).
|
||||
|
|
58
lib/macro.c
58
lib/macro.c
|
@ -4,6 +4,8 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
#define isblank(_c) ((_c) == ' ' || (_c) == '\t')
|
||||
#define iseol(_c) ((_c) == '\n' || (_c) == '\r')
|
||||
|
||||
#define STREQ(_t, _f, _fn) ((_fn) == (sizeof(_t)-1) && !strncmp((_t), (_f), (_fn)))
|
||||
#define FREE(_x) { if (_x) free((void *)_x); (_x) = NULL; }
|
||||
|
||||
|
@ -45,7 +47,6 @@ typedef struct MacroBuf {
|
|||
} MacroBuf;
|
||||
|
||||
#define SAVECHAR(_mb, _c) { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; }
|
||||
#define DELECHAR(_mb, _c) { if ((_mb)->t[-1] == (_c)) *((_mb)->t--) = '\0', (_mb)->nb++; }
|
||||
|
||||
static int expandMacro(MacroBuf *mb);
|
||||
|
||||
|
@ -183,25 +184,30 @@ rdcl(char *buf, size_t size, FILE *fp, int escapes)
|
|||
{
|
||||
char *q = buf;
|
||||
size_t nb = 0;
|
||||
size_t nread = 0;
|
||||
|
||||
*q = '\0';
|
||||
do {
|
||||
*q = '\0'; /* next char in buf */
|
||||
nb = 0;
|
||||
if (fgets(q, size, fp) == NULL) /* read next line */
|
||||
break;
|
||||
nb = strlen(q);
|
||||
q += nb - 1; /* last char in buf */
|
||||
*q-- = '\0'; /* trim newline */
|
||||
if (nb < 2 || *q != '\\') /* continue? */
|
||||
break;
|
||||
if (escapes) /* copy escape too */
|
||||
q++;
|
||||
else
|
||||
nread += nb;
|
||||
for (q += nb - 1; nb > 0 && iseol(*q); q--)
|
||||
nb--;
|
||||
*q++ = '\n'; /* next char in buf */
|
||||
if (!(nb > 0 && *q == '\\')) { /* continue? */
|
||||
*(++q) = '\0'; /* trim trailing \r, \n */
|
||||
break;
|
||||
}
|
||||
if (escapes) { /* copy escape too */
|
||||
q++;
|
||||
nb++;
|
||||
}
|
||||
size -= nb;
|
||||
if (*q == '\r') /* XXX avoid \r madness */
|
||||
*q = '\n';
|
||||
*(++q) = '\0'; /* next char in buf */
|
||||
} while (size > 0);
|
||||
return (nb > 0 ? buf : NULL);
|
||||
return (nread > 0 ? buf : NULL);
|
||||
}
|
||||
|
||||
/* Return text between pl and matching pr */
|
||||
|
@ -241,9 +247,9 @@ printMacro(MacroBuf *mb, const char *s, const char *se)
|
|||
if (s[-1] == '{')
|
||||
s--;
|
||||
|
||||
/* If not end-of-string, print only to newline or end-of-string ... */
|
||||
if (*(senl = se) != '\0' && (senl = strchr(senl, '\n')) == NULL)
|
||||
senl = se + strlen(se);
|
||||
/* Print only to first end-of-line (or end-of-string). */
|
||||
for (senl = se; *senl && !iseol(*senl); senl++)
|
||||
;
|
||||
|
||||
/* Limit trailing non-trace output */
|
||||
choplen = 61 - (2 * mb->depth);
|
||||
|
@ -273,11 +279,13 @@ printExpansion(MacroBuf *mb, const char *t, const char *te)
|
|||
}
|
||||
|
||||
/* Shorten output which contains newlines */
|
||||
while (te > t && te[-1] == '\n')
|
||||
while (te > t && iseol(te[-1]))
|
||||
te--;
|
||||
ellipsis = "";
|
||||
if (mb->depth > 0) {
|
||||
const char *tenl;
|
||||
|
||||
/* Skip to last line of expansion */
|
||||
while ((tenl = strchr(t, '\n')) && tenl < te)
|
||||
t = ++tenl;
|
||||
|
||||
|
@ -300,7 +308,7 @@ printExpansion(MacroBuf *mb, const char *t, const char *te)
|
|||
(_s)++;
|
||||
|
||||
#define SKIPNONBLANK(_s, _c) \
|
||||
while (((_c) = *(_s)) && !(isblank(_c) || c == '\n')) \
|
||||
while (((_c) = *(_s)) && !(isblank(_c) || iseol(_c))) \
|
||||
(_s)++;
|
||||
|
||||
#define COPYNAME(_ne, _s, _c) \
|
||||
|
@ -317,7 +325,7 @@ printExpansion(MacroBuf *mb, const char *t, const char *te)
|
|||
}
|
||||
|
||||
#define COPYBODY(_be, _s, _c) \
|
||||
{ while(((_c) = *(_s)) && (_c) != '\n') { \
|
||||
{ while(((_c) = *(_s)) && !iseol(_c)) { \
|
||||
if ((_c) == '\\') \
|
||||
(_s)++; \
|
||||
*(_be)++ = *(_s)++; \
|
||||
|
@ -410,7 +418,11 @@ doShellEscape(MacroBuf *mb, const char *cmd, size_t clen)
|
|||
SAVECHAR(mb, c);
|
||||
pclose(shf);
|
||||
|
||||
DELECHAR(mb, '\n'); /* XXX delete trailing newline (if any) */
|
||||
/* XXX delete trailing \r \n */
|
||||
while (iseol(mb->t[-1])) {
|
||||
*(mb->t--) = '\0';
|
||||
mb->nb++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -455,13 +467,13 @@ doDefine(MacroBuf *mb, const char *se, int level, int expandbody)
|
|||
COPYBODY(be, s, c);
|
||||
|
||||
/* Trim trailing blanks/newlines */
|
||||
while (--be >= b && (c = *be) && (isblank(c) || c == '\n'))
|
||||
while (--be >= b && (c = *be) && (isblank(c) || iseol(c)))
|
||||
;
|
||||
*(++be) = '\0'; /* one too far */
|
||||
}
|
||||
|
||||
/* Move scan over body */
|
||||
if (*s == '\n')
|
||||
while (iseol(*s))
|
||||
s++;
|
||||
se = s;
|
||||
|
||||
|
@ -502,7 +514,7 @@ doUndefine(MacroContext *mc, const char *se)
|
|||
COPYNAME(ne, s, c);
|
||||
|
||||
/* Move scan over body */
|
||||
if (*s == '\n')
|
||||
while (iseol(*s))
|
||||
s++;
|
||||
se = s;
|
||||
|
||||
|
@ -1026,7 +1038,7 @@ expandMacro(MacroBuf *mb)
|
|||
|
||||
if (STREQ("dump", f, fn)) {
|
||||
dumpMacroTable(mb->mc, NULL);
|
||||
if (*se == '\n')
|
||||
while (iseol(*se))
|
||||
se++;
|
||||
s = se;
|
||||
continue;
|
||||
|
|
38
po/rpm.pot
38
po/rpm.pot
|
@ -6,7 +6,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-08-16 12:06-0400\n"
|
||||
"POT-Creation-Date: 1999-08-16 14:44-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -2278,83 +2278,83 @@ msgstr ""
|
|||
msgid "cannot read header at %d for lookup"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:146
|
||||
#: ../lib/macro.c:148
|
||||
#, c-format
|
||||
msgid "======================== active %d empty %d\n"
|
||||
msgstr ""
|
||||
|
||||
#. XXX just in case
|
||||
#: ../lib/macro.c:235
|
||||
#: ../lib/macro.c:243
|
||||
#, c-format
|
||||
msgid "%3d>%*s(empty)"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:270
|
||||
#: ../lib/macro.c:278
|
||||
#, c-format
|
||||
msgid "%3d<%*s(empty)\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:443
|
||||
#: ../lib/macro.c:457
|
||||
msgid "Macro %%%s has unterminated body"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:469
|
||||
#: ../lib/macro.c:483
|
||||
msgid "Macro %%%s has illegal name (%%define)"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:475
|
||||
#: ../lib/macro.c:489
|
||||
msgid "Macro %%%s has unterminated opts"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:480
|
||||
#: ../lib/macro.c:494
|
||||
msgid "Macro %%%s has empty body"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:485
|
||||
#: ../lib/macro.c:499
|
||||
msgid "Macro %%%s failed to expand"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:510
|
||||
#: ../lib/macro.c:524
|
||||
msgid "Macro %%%s has illegal name (%%undefine)"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:586
|
||||
#: ../lib/macro.c:601
|
||||
msgid "Macro %%%s (%s) was not used below level %d"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:683
|
||||
#: ../lib/macro.c:698
|
||||
#, c-format
|
||||
msgid "Unknown option %c in %s(%s)"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:858
|
||||
#: ../lib/macro.c:870
|
||||
#, c-format
|
||||
msgid "Recursion depth(%d) greater than max(%d)"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:924 ../lib/macro.c:940
|
||||
#: ../lib/macro.c:936 ../lib/macro.c:952
|
||||
#, c-format
|
||||
msgid "Unterminated %c: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:980
|
||||
#: ../lib/macro.c:992
|
||||
msgid "A %% is followed by an unparseable macro"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:1103
|
||||
#: ../lib/macro.c:1115
|
||||
msgid "Macro %%%.*s not found, skipping"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:1184
|
||||
#: ../lib/macro.c:1196
|
||||
msgid "Target buffer overflow"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:1331 ../lib/macro.c:1339
|
||||
#: ../lib/macro.c:1343 ../lib/macro.c:1351
|
||||
#, c-format
|
||||
msgid "File %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: ../lib/macro.c:1342
|
||||
#: ../lib/macro.c:1354
|
||||
#, c-format
|
||||
msgid "File %s is smaller than %d bytes"
|
||||
msgstr ""
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
#define isblank(_c) ((_c) == ' ' || (_c) == '\t')
|
||||
#define iseol(_c) ((_c) == '\n' || (_c) == '\r')
|
||||
|
||||
#define STREQ(_t, _f, _fn) ((_fn) == (sizeof(_t)-1) && !strncmp((_t), (_f), (_fn)))
|
||||
#define FREE(_x) { if (_x) free((void *)_x); (_x) = NULL; }
|
||||
|
||||
|
@ -45,7 +47,6 @@ typedef struct MacroBuf {
|
|||
} MacroBuf;
|
||||
|
||||
#define SAVECHAR(_mb, _c) { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; }
|
||||
#define DELECHAR(_mb, _c) { if ((_mb)->t[-1] == (_c)) *((_mb)->t--) = '\0', (_mb)->nb++; }
|
||||
|
||||
static int expandMacro(MacroBuf *mb);
|
||||
|
||||
|
@ -183,25 +184,30 @@ rdcl(char *buf, size_t size, FILE *fp, int escapes)
|
|||
{
|
||||
char *q = buf;
|
||||
size_t nb = 0;
|
||||
size_t nread = 0;
|
||||
|
||||
*q = '\0';
|
||||
do {
|
||||
*q = '\0'; /* next char in buf */
|
||||
nb = 0;
|
||||
if (fgets(q, size, fp) == NULL) /* read next line */
|
||||
break;
|
||||
nb = strlen(q);
|
||||
q += nb - 1; /* last char in buf */
|
||||
*q-- = '\0'; /* trim newline */
|
||||
if (nb < 2 || *q != '\\') /* continue? */
|
||||
break;
|
||||
if (escapes) /* copy escape too */
|
||||
q++;
|
||||
else
|
||||
nread += nb;
|
||||
for (q += nb - 1; nb > 0 && iseol(*q); q--)
|
||||
nb--;
|
||||
*q++ = '\n'; /* next char in buf */
|
||||
if (!(nb > 0 && *q == '\\')) { /* continue? */
|
||||
*(++q) = '\0'; /* trim trailing \r, \n */
|
||||
break;
|
||||
}
|
||||
if (escapes) { /* copy escape too */
|
||||
q++;
|
||||
nb++;
|
||||
}
|
||||
size -= nb;
|
||||
if (*q == '\r') /* XXX avoid \r madness */
|
||||
*q = '\n';
|
||||
*(++q) = '\0'; /* next char in buf */
|
||||
} while (size > 0);
|
||||
return (nb > 0 ? buf : NULL);
|
||||
return (nread > 0 ? buf : NULL);
|
||||
}
|
||||
|
||||
/* Return text between pl and matching pr */
|
||||
|
@ -241,9 +247,9 @@ printMacro(MacroBuf *mb, const char *s, const char *se)
|
|||
if (s[-1] == '{')
|
||||
s--;
|
||||
|
||||
/* If not end-of-string, print only to newline or end-of-string ... */
|
||||
if (*(senl = se) != '\0' && (senl = strchr(senl, '\n')) == NULL)
|
||||
senl = se + strlen(se);
|
||||
/* Print only to first end-of-line (or end-of-string). */
|
||||
for (senl = se; *senl && !iseol(*senl); senl++)
|
||||
;
|
||||
|
||||
/* Limit trailing non-trace output */
|
||||
choplen = 61 - (2 * mb->depth);
|
||||
|
@ -273,11 +279,13 @@ printExpansion(MacroBuf *mb, const char *t, const char *te)
|
|||
}
|
||||
|
||||
/* Shorten output which contains newlines */
|
||||
while (te > t && te[-1] == '\n')
|
||||
while (te > t && iseol(te[-1]))
|
||||
te--;
|
||||
ellipsis = "";
|
||||
if (mb->depth > 0) {
|
||||
const char *tenl;
|
||||
|
||||
/* Skip to last line of expansion */
|
||||
while ((tenl = strchr(t, '\n')) && tenl < te)
|
||||
t = ++tenl;
|
||||
|
||||
|
@ -300,7 +308,7 @@ printExpansion(MacroBuf *mb, const char *t, const char *te)
|
|||
(_s)++;
|
||||
|
||||
#define SKIPNONBLANK(_s, _c) \
|
||||
while (((_c) = *(_s)) && !(isblank(_c) || c == '\n')) \
|
||||
while (((_c) = *(_s)) && !(isblank(_c) || iseol(_c))) \
|
||||
(_s)++;
|
||||
|
||||
#define COPYNAME(_ne, _s, _c) \
|
||||
|
@ -317,7 +325,7 @@ printExpansion(MacroBuf *mb, const char *t, const char *te)
|
|||
}
|
||||
|
||||
#define COPYBODY(_be, _s, _c) \
|
||||
{ while(((_c) = *(_s)) && (_c) != '\n') { \
|
||||
{ while(((_c) = *(_s)) && !iseol(_c)) { \
|
||||
if ((_c) == '\\') \
|
||||
(_s)++; \
|
||||
*(_be)++ = *(_s)++; \
|
||||
|
@ -410,7 +418,11 @@ doShellEscape(MacroBuf *mb, const char *cmd, size_t clen)
|
|||
SAVECHAR(mb, c);
|
||||
pclose(shf);
|
||||
|
||||
DELECHAR(mb, '\n'); /* XXX delete trailing newline (if any) */
|
||||
/* XXX delete trailing \r \n */
|
||||
while (iseol(mb->t[-1])) {
|
||||
*(mb->t--) = '\0';
|
||||
mb->nb++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -455,13 +467,13 @@ doDefine(MacroBuf *mb, const char *se, int level, int expandbody)
|
|||
COPYBODY(be, s, c);
|
||||
|
||||
/* Trim trailing blanks/newlines */
|
||||
while (--be >= b && (c = *be) && (isblank(c) || c == '\n'))
|
||||
while (--be >= b && (c = *be) && (isblank(c) || iseol(c)))
|
||||
;
|
||||
*(++be) = '\0'; /* one too far */
|
||||
}
|
||||
|
||||
/* Move scan over body */
|
||||
if (*s == '\n')
|
||||
while (iseol(*s))
|
||||
s++;
|
||||
se = s;
|
||||
|
||||
|
@ -502,7 +514,7 @@ doUndefine(MacroContext *mc, const char *se)
|
|||
COPYNAME(ne, s, c);
|
||||
|
||||
/* Move scan over body */
|
||||
if (*s == '\n')
|
||||
while (iseol(*s))
|
||||
s++;
|
||||
se = s;
|
||||
|
||||
|
@ -1026,7 +1038,7 @@ expandMacro(MacroBuf *mb)
|
|||
|
||||
if (STREQ("dump", f, fn)) {
|
||||
dumpMacroTable(mb->mc, NULL);
|
||||
if (*se == '\n')
|
||||
while (iseol(*se))
|
||||
se++;
|
||||
s = se;
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue