Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified autogen.sh
100644 → 100755
Empty file.
63 changes: 45 additions & 18 deletions readtags.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,19 +870,23 @@ static void terminate (tagFile *const file)
static tagResult readNext (tagFile *const file, tagEntry *const entry)
{
tagResult result;
if (file == NULL || ! file->initialized)

if (file == NULL)
return TagFailure;

if (! file->initialized)
{
file->err = TagErrnoInvalidArgument;
result = TagFailure;
}
else if (! readTagLine (file, &file->err))
result = TagFailure;
else
{
result = (entry != NULL)
? parseTagLine (file, entry, &file->err)
: TagSuccess;
return TagFailure;
}

if (! readTagLine (file, &file->err))
return TagFailure;

result = (entry != NULL)
? parseTagLine (file, entry, &file->err)
: TagSuccess;

return result;
}

Expand Down Expand Up @@ -1034,7 +1038,10 @@ static tagResult findSequentialFull (tagFile *const file,
int (* isAcceptable) (tagFile *const, void *),
void *data)
{
if (file == NULL || !file->initialized || file->err)
if (file == NULL)
return TagFailure;

if (!file->initialized || file->err)
{
file->err = TagErrnoInvalidArgument;
return TagFailure;
Expand Down Expand Up @@ -1149,9 +1156,12 @@ static tagResult findNext (tagFile *const file, tagEntry *const entry)

static tagResult findPseudoTag (tagFile *const file, int rewindBeforeFinding, tagEntry *const entry)
{
if (file == NULL || (!file->initialized) || file->err)
if (file == NULL)
return TagFailure;

if (!file->initialized || file->err)
{
file->err= TagErrnoInvalidArgument;;
file->err = TagErrnoInvalidArgument;
return TagFailure;
}

Expand Down Expand Up @@ -1182,7 +1192,10 @@ extern tagFile *tagsOpen (const char *const filePath, tagFileInfo *const info)

extern tagResult tagsSetSortType (tagFile *const file, const tagSortType type)
{
if (file == NULL || (!file->initialized) || file->err)
if (file == NULL)
return TagFailure;

if (!file->initialized || file->err)
{
file->err = TagErrnoInvalidArgument;
return TagFailure;
Expand All @@ -1203,7 +1216,10 @@ extern tagResult tagsSetSortType (tagFile *const file, const tagSortType type)

extern tagResult tagsFirst (tagFile *const file, tagEntry *const entry)
{
if (file == NULL || (!file->initialized) || file->err)
if (file == NULL)
return TagFailure;

if (!file->initialized || file->err)
{
file->err = TagErrnoInvalidArgument;
return TagFailure;
Expand All @@ -1216,7 +1232,10 @@ extern tagResult tagsFirst (tagFile *const file, tagEntry *const entry)

extern tagResult tagsNext (tagFile *const file, tagEntry *const entry)
{
if (file == NULL || (!file->initialized) || file->err)
if (file == NULL)
return TagFailure;

if (!file->initialized || file->err)
{
file->err = TagErrnoInvalidArgument;
return TagFailure;
Expand All @@ -1236,21 +1255,29 @@ extern const char *tagsField (const tagEntry *const entry, const char *const key
extern tagResult tagsFind (tagFile *const file, tagEntry *const entry,
const char *const name, const int options)
{
if (file == NULL || !file->initialized || file->err)
if (file == NULL)
return TagFailure;

if (!file->initialized || file->err)
{
file->err = TagErrnoInvalidArgument;
return TagFailure;
}

return find (file, entry, name, options);
}

extern tagResult tagsFindNext (tagFile *const file, tagEntry *const entry)
{
if (file == NULL || !file->initialized || file->err)
if (file == NULL)
return TagFailure;

if (!file->initialized || file->err)
{
file->err = TagErrnoInvalidArgument;
return TagFailure;
}

return findNext (file, entry);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test-api-tagsFind.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ check_finding0 (tagFile *t, const char *name, const int options,
if (err == x->err)
{
if (err == 0)
fprintf (stderr, "not found, and it is expected\n", err);
fprintf (stderr, "not found, and it is expected\n");
else
fprintf (stderr, "error as expected: %d\n", err);
continue;
}
else
{
fprintf (stderr, "errer number doesn't match: %d (expected: %d)\n",
fprintf (stderr, "error number doesn't match: %d (expected: %d)\n",
err, x->err);
return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/test-api-tagsOpen.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ main (void)
for (int i = 0; i < 6; i++)
{
char tagf_name_tmpl [] = "./api-tagsOpen-incomplete-program-author-%d.tags";
char tagf_name [sizeof (tagf_name_tmpl)];
char tagf_name [sizeof (tagf_name_tmpl) - 1];
fprintf (stderr, "opening a tags file with incomplete PROGRAM_AUTHOR field [trimming level: %d]...", i);
sprintf (tagf_name, tagf_name_tmpl, i);
snprintf (tagf_name, sizeof (tagf_name), tagf_name_tmpl, i);
t = tagsOpen (tagf_name, &info);
if (t == NULL)
{
Expand Down
1 change: 0 additions & 1 deletion tests/test-fix-null-deref.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ main (void)
fprintf (stderr, "ok\n");

tagEntry e;
tagResult r;

/* Without fix, this program crashes in tagsFirst(). */
tagsFirst (t, &e);
Expand Down