Skip to content

Commit

Permalink
Merge pull request #1934 from masatake/cleanup-inclusions-2
Browse files Browse the repository at this point in the history
Defining interface for parsers (part 3 of N)
  • Loading branch information
masatake committed Nov 26, 2018
2 parents bda19d5 + 455d436 commit a74b847
Show file tree
Hide file tree
Showing 51 changed files with 360 additions and 222 deletions.
2 changes: 1 addition & 1 deletion main/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <string.h>
#include <ctype.h>

#include "args.h"
#include "args_p.h"
#include "debug.h"
#include "routines.h"
#include "vstring.h"
Expand Down
6 changes: 3 additions & 3 deletions main/args.h → main/args_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*
* Defines external interface to command line argument reading.
*/
#ifndef CTAGS_MAIN_ARGS_H
#define CTAGS_MAIN_ARGS_H
#ifndef CTAGS_MAIN_ARGS_PRIVATE_H
#define CTAGS_MAIN_ARGS_PRIVATE_H

/*
* INCLUDE FILES
Expand Down Expand Up @@ -54,4 +54,4 @@ extern void argSetLineMode (Arguments* const current);
extern void argForth (Arguments* const current);
extern void argDelete (Arguments* const current);

#endif /* CTAGS_MAIN_ARGS_H */
#endif /* CTAGS_MAIN_ARGS_PRIVATE_H */
2 changes: 1 addition & 1 deletion main/colprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
#include "general.h" /* must always come first */

#include "colprint.h"
#include "colprint_p.h"
#include "ptrarray.h"
#include "routines.h"
#include "strlist.h"
Expand Down
6 changes: 3 additions & 3 deletions main/colprint.h → main/colprint_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* GNU General Public License version 2 or (at your option) any later version.
*
*/
#ifndef CTAGS_MAIN_COLPRINT_H
#define CTAGS_MAIN_COLPRINT_H
#ifndef CTAGS_MAIN_COLPRINT_PRIVATE_H
#define CTAGS_MAIN_COLPRINT_PRIVATE_H

#include "general.h"

Expand Down Expand Up @@ -34,4 +34,4 @@ void colprintLineAppendColumnBool (struct colprintLine *line, bool column);

const char *colprintLineGetColumn (struct colprintLine *line, unsigned int column);

#endif /* CTAGS_MAIN_COLPRINT_H */
#endif /* CTAGS_MAIN_COLPRINT_PRIVATE_H */
1 change: 1 addition & 0 deletions main/dependency.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "options.h"
#include "parse_p.h"
#include "read.h"
#include "routines.h"
#include "subparser.h"
#include "xtag.h"

Expand Down
7 changes: 4 additions & 3 deletions main/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@
#include "debug.h"
#include "entry_p.h"
#include "field.h"
#include "fmt.h"
#include "fmt_p.h"
#include "kind.h"
#include "main.h"
#include "nestlevel.h"
#include "options_p.h"
#include "ptag.h"
#include "ptag_p.h"
#include "read.h"
#include "routines.h"
#include "routines_p.h"
#include "parse_p.h"
#include "ptrarray.h"
#include "sort.h"
#include "strlist.h"
#include "subparser.h"
#include "trashbox.h"
#include "writer.h"
#include "writer_p.h"
#include "xtag.h"

/*
Expand Down
1 change: 1 addition & 0 deletions main/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "error.h"
#include "options_p.h"
#include "routines_p.h"

#ifdef HAVE_JANSSON
#include <jansson.h>
Expand Down
4 changes: 2 additions & 2 deletions main/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#define CTAGS_MAIN_FIELD_H

#include "general.h"
#include "colprint.h"
#include "writer.h"
#include "colprint_p.h"
#include "writer_p.h"
#include "types.h"

#include "vstring.h"
Expand Down
2 changes: 1 addition & 1 deletion main/flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <stdio.h>

#include "ctags.h"
#include "flags.h"
#include "flags_p.h"
#include "vstring.h"
#include "routines.h"

Expand Down
8 changes: 4 additions & 4 deletions main/flags.h → main/flags_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
*
* Defines external interface to option processing.
*/
#ifndef CTAGS_MAIN_FLAGS_H
#define CTAGS_MAIN_FLAGS_H
#ifndef CTAGS_MAIN_FLAGS_PRIVATE_H
#define CTAGS_MAIN_FLAGS_PRIVATE_H

#include "general.h"
#include "colprint.h"
#include "colprint_p.h"


#define LONG_FLAGS_OPEN '{'
Expand All @@ -32,4 +32,4 @@ extern struct colprintTable * flagsColprintTableNew (void);
extern void flagsColprintAddDefinitions (struct colprintTable *table, flagDefinition* def, unsigned int ndefs);
extern void flagsColprintTablePrint (struct colprintTable *table,
bool withListHeader, bool machinable, FILE *fp);
#endif /* CTAGS_MAIN_FLAGS_H */
#endif /* CTAGS_MAIN_FLAGS_PRIVATE_H */
2 changes: 1 addition & 1 deletion main/fmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "general.h"
#include "debug.h"
#include "entry_p.h"
#include "fmt.h"
#include "fmt_p.h"
#include "field.h"
#include "parse.h"
#include "routines.h"
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions main/interactive_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "general.h"
#include "options_p.h"
#include "routines.h"


struct interactiveModeArgs
Expand Down
1 change: 1 addition & 0 deletions main/keyword.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "debug.h"
#include "keyword.h"
#include "keyword_p.h"
#include "parse.h"
#include "routines.h"

Expand Down
15 changes: 3 additions & 12 deletions main/keyword.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
* INCLUDE FILES
*/
#include "general.h" /* must always come first */

#include "types.h"
#include "vstring.h"

#include <stdio.h>


/*
* MACROS
*/
#define KEYWORD_NONE -1

/*
Expand All @@ -28,12 +26,5 @@
extern void addKeyword (const char *const string, langType language, int value);
extern int lookupKeyword (const char *const string, langType language);
extern int lookupCaseKeyword (const char *const string, langType language);
extern void freeKeywordTable (void);

extern void dumpKeywordTable (FILE *fp);

#ifdef DEBUG
extern void printKeywordTable (void);
#endif

#endif /* CTAGS_MAIN_KEYWORD_H */
26 changes: 26 additions & 0 deletions main/keyword_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 1998-2002, Darren Hiebert
*
* This source code is released for free distribution under the terms of the
* GNU General Public License version 2 or (at your option) any later version.
*
* main part private interface to keyword.c
*/
#ifndef CTAGS_MAIN_KEYWORD_PRIVATE_H
#define CTAGS_MAIN_KEYWORD_PRIVATE_H

/*
* INCLUDE FILES
*/
#include "general.h" /* must always come first */
#include <stdio.h>

extern void freeKeywordTable (void);

extern void dumpKeywordTable (FILE *fp);

#ifdef DEBUG
extern void printKeywordTable (void);
#endif

#endif /* CTAGS_MAIN_KEYWORD_PRIVATE_H */
1 change: 1 addition & 0 deletions main/kind.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "kind.h"
#include "parse_p.h"
#include "options.h"
#include "routines.h"
#include "vstring.h"

typedef struct sRoleObject {
Expand Down
5 changes: 3 additions & 2 deletions main/lregex.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@
#include <regex.h>

#include "debug.h"
#include "colprint.h"
#include "colprint_p.h"
#include "entry.h"
#include "flags.h"
#include "flags_p.h"
#include "htable.h"
#include "kind.h"
#include "options.h"
#include "parse_p.h"
#include "read.h"
#include "routines.h"
#include "routines_p.h"
#include "trashbox.h"

static bool regexAvailable = false;
Expand Down
52 changes: 7 additions & 45 deletions main/lregex.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@

#ifndef CTAGS_MAIN_LREGEX_H
#define CTAGS_MAIN_LREGEX_H

/*
* INCLUDE FILES
*/
#include "general.h"

/*
* DATA DECLARATIONS
*/
typedef struct sTagRegexTable {
const char *const regex;
const char* const name;
Expand All @@ -31,55 +38,10 @@ typedef struct {
size_t length; /* length of match */
} regexMatch;

enum regexParserType {
REG_PARSER_SINGLE_LINE,
REG_PARSER_MULTI_LINE,
REG_PARSER_MULTI_TABLE,
};

/* Return value is referred when {exclusive} is also specified.
The input line is consumed when "{exclusive}" is specified and
the value returned from the callback function is true. */
typedef bool (*regexCallback) (const char *line, const regexMatch *matches, unsigned int count,
void *userData);

struct lregexControlBlock;
extern struct lregexControlBlock* allocLregexControlBlock (parserDefinition *parser);
extern void freeLregexControlBlock (struct lregexControlBlock* lcb);

extern void processTagRegexOption (struct lregexControlBlock *lcb,
enum regexParserType,
const char* const parameter);
extern void addTagRegex (struct lregexControlBlock *lcb, const char* const regex,
const char* const name, const char* const kinds, const char* const flags,
bool *disabled);
extern void addTagMultiLineRegex (struct lregexControlBlock *lcb, const char* const regex,
const char* const name, const char* const kinds, const char* const flags,
bool *disabled);
extern void addTagMultiTableRegex(struct lregexControlBlock *lcb,
const char* const table_name,
const char* const regex,
const char* const name, const char* const kinds, const char* const flags,
bool *disabled);

extern bool matchRegex (struct lregexControlBlock *lcb, const vString* const line);
extern bool hasScopeActionInRegex (struct lregexControlBlock *lcb);
extern void addCallbackRegex (struct lregexControlBlock *lcb,
const char* const regex,
const char* const flags,
const regexCallback callback,
bool *disabled,
void * userData);
extern bool regexNeedsMultilineBuffer (struct lregexControlBlock *lcb);
extern bool matchMultilineRegex (struct lregexControlBlock *lcb, const vString* const allLines);
extern bool matchMultitableRegex (struct lregexControlBlock *lcb, const vString* const allLines);

extern void notifyRegexInputStart (struct lregexControlBlock *lcb);
extern void notifyRegexInputEnd (struct lregexControlBlock *lcb);

extern void addRegexTable (struct lregexControlBlock *lcb, const char *name);
extern void extendRegexTable (struct lregexControlBlock *lcb, const char *src, const char *dist);

extern void printMultitableStatistics (struct lregexControlBlock *lcb, FILE *vfp);

#endif /* CTAGS_MAIN_LREGEX_H */
76 changes: 76 additions & 0 deletions main/lregex_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2000-2003, Darren Hiebert
* Copyright (c) 2017, Red Hat, Inc.
* Copyright (c) 2017, Masatake YAMATO
*
* This source code is released for free distribution under the terms of the
* GNU General Public License version 2 or (at your option) any later version.
*
* This module contains functions for applying regular expression matching.
*
* The code for utilizing the Gnu regex package with regards to processing the
* regex option and checking for regex matches was adapted from routines in
* Gnu etags.
*/
#ifndef CTAGS_MAIN_LREGEX_PRIVATE_H
#define CTAGS_MAIN_LREGEX_PRIVATE_H

/*
* INCLUDE FILES
*/
#include "general.h"
#include "lregex.h"

/*
* DATA DECLARATIONS
*/
enum regexParserType {
REG_PARSER_SINGLE_LINE,
REG_PARSER_MULTI_LINE,
REG_PARSER_MULTI_TABLE,
};

struct lregexControlBlock;

/*
* FUNCTION PROTOTYPES
*/
extern struct lregexControlBlock* allocLregexControlBlock (parserDefinition *parser);
extern void freeLregexControlBlock (struct lregexControlBlock* lcb);

extern void processTagRegexOption (struct lregexControlBlock *lcb,
enum regexParserType,
const char* const parameter);
extern void addTagRegex (struct lregexControlBlock *lcb, const char* const regex,
const char* const name, const char* const kinds, const char* const flags,
bool *disabled);
extern void addTagMultiLineRegex (struct lregexControlBlock *lcb, const char* const regex,
const char* const name, const char* const kinds, const char* const flags,
bool *disabled);
extern void addTagMultiTableRegex(struct lregexControlBlock *lcb,
const char* const table_name,
const char* const regex,
const char* const name, const char* const kinds, const char* const flags,
bool *disabled);

extern bool matchRegex (struct lregexControlBlock *lcb, const vString* const line);
extern bool hasScopeActionInRegex (struct lregexControlBlock *lcb);
extern void addCallbackRegex (struct lregexControlBlock *lcb,
const char* const regex,
const char* const flags,
const regexCallback callback,
bool *disabled,
void * userData);
extern bool regexNeedsMultilineBuffer (struct lregexControlBlock *lcb);
extern bool matchMultilineRegex (struct lregexControlBlock *lcb, const vString* const allLines);
extern bool matchMultitableRegex (struct lregexControlBlock *lcb, const vString* const allLines);

extern void notifyRegexInputStart (struct lregexControlBlock *lcb);
extern void notifyRegexInputEnd (struct lregexControlBlock *lcb);

extern void addRegexTable (struct lregexControlBlock *lcb, const char *name);
extern void extendRegexTable (struct lregexControlBlock *lcb, const char *src, const char *dist);

extern void printMultitableStatistics (struct lregexControlBlock *lcb, FILE *vfp);

#endif /* CTAGS_MAIN_LREGEX_PRIVATEH */
Loading

0 comments on commit a74b847

Please sign in to comment.