[CWB] MAX_LINE_LENGTH

Hardie, Andrew a.hardie at lancaster.ac.uk
Tue Mar 1 19:13:46 CET 2011


I have spotted this before and came to the conclusion it is a workaround to avoid #including cl/globals.h in cwb-align-* . This is both right and wrong -- programs built against the CL are not supposed to use its internal header files like globals.h (so this is correct) but using literal integers is dirty (so this is incorrect).

The Right Thing is probably to change MAX_LINE_LENGTH to CL_MAX_LINE_LENGTH everywhere, move its definition to cl.h, and use it in cwb-align-* as everywhere else. In principle, I can't see any harm in exposing a default-char-buffer-size constant in the API.... especially as it is now needed in order to use the new (public) function cl_strcpy()... and of course this would meet your needs too, Alberto.

That said, in practice lots of other cwb-utils do actually #include cl/globals.h. Without knowing why doing this was avoided in align-encode and align-show (Stefan - was this you?), I would be reluctant to start changing things.

Andrew.


-----Original Message-----
From: cwb-bounces at sslmit.unibo.it [mailto:cwb-bounces at sslmit.unibo.it] On Behalf Of Alberto Simões
Sent: 01 March 2011 17:28
To: Open source development of the Corpus WorkBench
Subject: [CWB] MAX_LINE_LENGTH

Hello

Under cl/globals.h, MAX_LINE_LENGTH is defined (to 4096).

utils/cwb-align-encode.c has:

171:  char line[4096];          /* one line of input from <infile> */
219:  fgets(line, 4096, af);
327:    if (NULL == fgets(line, 4096, af))

and, utils/cwb-align-show.c

178:      char line[4096];
180:        fgets(line, 4096, af);
214:  char line[4096];
218:  fgets(line, 4096, f);
231:  char line[4096];
245:  if (NULL == fgets(line, 4096, f))
329:  char line[4096];               /* input buffer for .align file */
330:  char cmd[4096];                /* interactive command input */
364:  fgets(line, 4096, af);
407:    fgets(cmd, 4096, stdin);

I think most of these refer to MAX_LINE_LENGTH.

Am I correct? Should I prepare a patch to change it?

Thank you
ambs

PS: why do I want this? because I will need, probably to expand this 
value in a custom build, and it gets easier to change only the definition :)

-- 
Alberto Simoes
CCTC-UM / CEHUM
_______________________________________________
CWB mailing list
CWB at sslmit.unibo.it
http://devel.sslmit.unibo.it/mailman/listinfo/cwb


More information about the CWB mailing list