Skip to content

Commit 7617557

Browse files
committed
readtags,cosmetic: lift up "else" block
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent d01023d commit 7617557

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

extra-cmds/readtags-cmd.c

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ static void findTag (const char *const name, const int options)
336336
{
337337
tagFileInfo info;
338338
tagEntry entry;
339+
int err = 0;
339340
tagFile *const file = openTags (TagFileName, &info);
340341
if (file == NULL || !info.status.opened)
341342
{
@@ -345,45 +346,43 @@ static void findTag (const char *const name, const int options)
345346
tagsClose (file);
346347
exit (1);
347348
}
348-
else
349+
350+
if (SortOverride)
349351
{
350-
int err = 0;
351-
if (SortOverride)
352-
{
353-
if (tagsSetSortType (file, SortMethod) != TagSuccess)
354-
{
355-
err = tagsGetErrno (file);
356-
fprintf (stderr, "%s: cannot set sort type to %d: %s\n",
357-
ProgramName,
358-
SortMethod,
359-
tagsStrerror (err));
360-
exit (1);
361-
}
362-
}
363-
if (debugMode)
364-
fprintf (stderr, "%s: searching for \"%s\" in \"%s\"\n",
365-
ProgramName, name, TagFileName);
366-
if (tagsFind (file, &entry, name, options) == TagSuccess)
367-
walkTags (file, &entry, tagsFindNext,
368-
#ifdef READTAGS_DSL
369-
Formatter? printTagWithFormatter:
370-
#endif
371-
printTag);
372-
else if ((err = tagsGetErrno (file)) != 0)
352+
if (tagsSetSortType (file, SortMethod) != TagSuccess)
373353
{
374-
fprintf (stderr, "%s: error in tagsFind(): %s\n",
354+
err = tagsGetErrno (file);
355+
fprintf (stderr, "%s: cannot set sort type to %d: %s\n",
375356
ProgramName,
357+
SortMethod,
376358
tagsStrerror (err));
377359
exit (1);
378360
}
379-
tagsClose (file);
380361
}
362+
if (debugMode)
363+
fprintf (stderr, "%s: searching for \"%s\" in \"%s\"\n",
364+
ProgramName, name, TagFileName);
365+
if (tagsFind (file, &entry, name, options) == TagSuccess)
366+
walkTags (file, &entry, tagsFindNext,
367+
#ifdef READTAGS_DSL
368+
Formatter? printTagWithFormatter:
369+
#endif
370+
printTag);
371+
else if ((err = tagsGetErrno (file)) != 0)
372+
{
373+
fprintf (stderr, "%s: error in tagsFind(): %s\n",
374+
ProgramName,
375+
tagsStrerror (err));
376+
exit (1);
377+
}
378+
tagsClose (file);
381379
}
382380

383381
static void listTags (int pseudoTags)
384382
{
385383
tagFileInfo info;
386384
tagEntry entry;
385+
int err = 0;
387386
tagFile *const file = openTags (TagFileName, &info);
388387
if (file == NULL || !info.status.opened)
389388
{
@@ -395,9 +394,9 @@ static void listTags (int pseudoTags)
395394
tagsClose (file);
396395
exit (1);
397396
}
398-
else if (pseudoTags)
397+
398+
if (pseudoTags)
399399
{
400-
int err = 0;
401400
if (tagsFirstPseudoTag (file, &entry) == TagSuccess)
402401
walkTags (file, &entry, tagsNextPseudoTag, printPseudoTag);
403402
else if ((err = tagsGetErrno (file)) != 0)
@@ -407,11 +406,9 @@ static void listTags (int pseudoTags)
407406
tagsStrerror (err));
408407
exit (1);
409408
}
410-
tagsClose (file);
411409
}
412410
else
413411
{
414-
int err = 0;
415412
if (tagsFirst (file, &entry) == TagSuccess)
416413
walkTags (file, &entry, tagsNext,
417414
#ifdef READTAGS_DSL
@@ -425,8 +422,8 @@ static void listTags (int pseudoTags)
425422
tagsStrerror (err));
426423
exit (1);
427424
}
428-
tagsClose (file);
429425
}
426+
tagsClose (file);
430427
}
431428

432429
static const char *const Usage =

0 commit comments

Comments
 (0)