build: make size of line buffer for .spec parsing configurable via %_spec_line_buffer_size

Based on http://rpm5.org/cvs/chngview?cn=9215

In the meantime, decrease this default line buffer size from 80K to 64K.
This commit is contained in:
Дмитрий Левин 2012-03-19 01:29:03 +00:00
parent a470a11bac
commit e870902a7b
3 changed files with 8 additions and 4 deletions

View File

@ -145,7 +145,7 @@ static int copyNextLine(Spec spec, OFI_t *ofi, int strip)
int pc = 0, bc = 0, nc = 0;
char *from, *to, *p, *end;
to = spec->lbufPtr ? spec->lbufPtr : spec->lbuf;
end = spec->lbuf + sizeof(spec->lbuf) - 1;
end = spec->lbuf + spec->lbuf_len - 1;
from = ofi->readPtr;
ch = ' ';
while (*from && ch != '\n' && to < end)
@ -202,7 +202,7 @@ static int copyNextLine(Spec spec, OFI_t *ofi, int strip)
if (!failed_ok)
failed_ok = (strip & STRIP_COMMENTS) && isCommentLine(spec->lbuf);
rpmSetBuiltinMacroLookupFailedOK(failed_ok);
rc = expandMacros(spec, spec->macros, spec->lbuf, sizeof(spec->lbuf));
rc = expandMacros(spec, spec->macros, spec->lbuf, spec->lbuf_len);
rpmSetBuiltinMacroLookupFailedOK(saved_lookup_failed);
if (rc) {
rpmError(RPMERR_BADSPEC, _("line %d: %s\n"),

View File

@ -100,8 +100,9 @@ struct SpecStruct {
/*@owned@*/ /*@null@*/ spectags st;
/*@owned@*/ struct OpenFileInfo * fileStack;
char lbuf[10*BUFSIZ];
char *lbuf;
char *lbufPtr;
size_t lbuf_len;
char nextpeekc;
/*@dependent@*/ char * nextline;
/*@dependent@*/ char * line;

View File

@ -440,7 +440,8 @@ Spec newSpec(void)
spec->st = newSt();
spec->fileStack = NULL;
spec->lbuf[0] = '\0';
spec->lbuf_len = rpmExpandNumeric("%{?_spec_line_buffer_size}%{!?_spec_line_buffer_size:65536}");
spec->lbuf = xcalloc(1, spec->lbuf_len);
spec->line = spec->lbuf;
spec->nextline = NULL;
spec->nextpeekc = '\0';
@ -496,6 +497,8 @@ Spec freeSpec(Spec spec)
if (spec == NULL) return NULL;
spec->lbuf = _free(spec->lbuf);
spec->sl = freeSl(spec->sl);
spec->st = freeSt(spec->st);