Rename readLine() to readLineRaw()

Plus make some minor changes in its implementation to match uctags.
This commit is contained in:
Jiří Techet 2016-07-30 13:10:10 +02:00
parent bbbbb309ba
commit ba2209e4a6
7 changed files with 19 additions and 20 deletions

View File

@ -212,7 +212,7 @@ static long unsigned int updatePseudoTags (MIO *const mio)
Assert (classLength < maxClassLength);
mio_getpos (mio, &startOfLine);
line = readLine (TagFile.vLine, mio);
line = readLineRaw (TagFile.vLine, mio);
while (line != NULL && line [0] == class [0])
{
++linesRead;
@ -228,12 +228,12 @@ static long unsigned int updatePseudoTags (MIO *const mio)
}
mio_getpos (mio, &startOfLine);
}
line = readLine (TagFile.vLine, mio);
line = readLineRaw (TagFile.vLine, mio);
}
while (line != NULL) /* skip to end of file */
{
++linesRead;
line = readLine (TagFile.vLine, mio);
line = readLineRaw (TagFile.vLine, mio);
}
return linesRead;
}
@ -253,7 +253,7 @@ static boolean isTagFile (const char *const filename)
ok = TRUE;
else if (mio != NULL)
{
const char *line = readLine (TagFile.vLine, mio);
const char *line = readLineRaw (TagFile.vLine, mio);
if (line == NULL)
ok = TRUE;

View File

@ -402,7 +402,7 @@ static void processLanguageRegex (const langType language,
else
{
vString* const regex = vStringNew ();
while (readLine (regex, mio))
while (readLineRaw (regex, mio))
addLanguageRegex (language, vStringValue (regex));
mio_free (mio);
vStringDelete (regex);

View File

@ -170,7 +170,7 @@ static langType getInterpreterLanguage (const char *const fileName)
if (fp != NULL)
{
vString* const vLine = vStringNew ();
const char* const line = readLine (vLine, fp);
const char* const line = readLineRaw (vLine, fp);
if (line != NULL && line [0] == '#' && line [1] == '!')
{
const char* const lastSlash = strrchr (line, '/');

View File

@ -532,17 +532,16 @@ extern const unsigned char *readLineFromInputFile (void)
return result;
}
/*
* Source file line reading with automatic buffer sizing
* Raw file line reading with automatic buffer sizing
*/
extern char *readLine (vString *const vLine, MIO *const mio)
extern char *readLineRaw (vString *const vLine, MIO *const fp)
{
char *result = NULL;
vStringClear (vLine);
if (mio == NULL) /* to free memory allocated to buffer */
error (FATAL, "NULL MIO pointer");
if (fp == NULL) /* to free memory allocated to buffer */
error (FATAL, "NULL file pointer");
else
{
boolean reReadLine;
@ -555,15 +554,15 @@ extern char *readLine (vString *const vLine, MIO *const mio)
do
{
char *const pLastChar = vStringValue (vLine) + vStringSize (vLine) -2;
MIOPos startOfLine;
long startOfLine;
mio_getpos (mio, &startOfLine);
startOfLine = mio_tell(fp);
reReadLine = FALSE;
*pLastChar = '\0';
result = mio_gets (mio, vStringValue (vLine), (int) vStringSize (vLine));
result = mio_gets (fp, vStringValue (vLine), (int) vStringSize (vLine));
if (result == NULL)
{
if (! mio_eof (mio))
if (! mio_eof (fp))
error (FATAL | PERROR, "Failure on attempt to read file");
}
else if (*pLastChar != '\0' &&
@ -572,7 +571,7 @@ extern char *readLine (vString *const vLine, MIO *const mio)
/* buffer overflow */
reReadLine = vStringAutoResize (vLine);
if (reReadLine)
mio_setpos (mio, &startOfLine);
mio_seek (fp, startOfLine, SEEK_SET);
else
error (FATAL | PERROR, "input line too big; out of memory");
}
@ -609,7 +608,7 @@ extern char *readSourceLine (vString *const vLine, MIOPos location,
mio_setpos (File.fp, &location);
if (pSeekValue != NULL)
*pSeekValue = mio_tell (File.fp);
result = readLine (vLine, File.fp);
result = readLineRaw (vLine, File.fp);
if (result == NULL)
error (FATAL, "Unexpected end of file: %s", getInputFileName ());
mio_setpos (File.fp, &orignalPosition);

View File

@ -111,7 +111,7 @@ extern int getNthPrevCFromInputFile (unsigned int nth, int def);
extern int skipToCharacterInInputFile (int c);
extern void ungetcToInputFile (int c);
extern const unsigned char *readLineFromInputFile (void);
extern char *readLine (vString *const vLine, MIO *const mio);
extern char *readLineRaw (vString *const vLine, MIO *const fp);
extern char *readSourceLine (vString *const vLine, MIOPos location, long *const pSeekValue);
extern boolean bufferOpen (unsigned char *buffer, size_t buffer_size,
const char *const fileName, const langType language );

View File

@ -178,7 +178,7 @@ extern void internalSortTags (const boolean toStdout)
failedSort (mio, NULL);
for (i = 0 ; i < numTags && ! mio_eof (mio) ; )
{
line = readLine (vLine, mio);
line = readLineRaw (vLine, mio);
if (line == NULL)
{
if (! mio_eof (mio))

View File

@ -97,7 +97,7 @@ extern stringList* stringListNewFromFile (const char* const fileName)
while (! mio_eof (mio))
{
vString* const str = vStringNew ();
readLine (str, mio);
readLineRaw (str, mio);
vStringStripTrailing (str);
if (vStringLength (str) > 0)
stringListAdd (result, str);