summaryrefslogtreecommitdiff
path: root/nonints.h
diff options
context:
space:
mode:
Diffstat (limited to 'nonints.h')
-rw-r--r--nonints.h176
1 files changed, 129 insertions, 47 deletions
diff --git a/nonints.h b/nonints.h
index 6bcbd7690adb..ba2e3bbbe4ed 100644
--- a/nonints.h
+++ b/nonints.h
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.102 2020/08/30 19:56:02 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.149 2020/11/01 00:24:57 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -73,32 +73,32 @@
*/
/* arch.c */
-Boolean Arch_ParseArchive(char **, Lst, GNode *);
+void Arch_Init(void);
+void Arch_End(void);
+
+Boolean Arch_ParseArchive(char **, GNodeList *, GNode *);
void Arch_Touch(GNode *);
void Arch_TouchLib(GNode *);
time_t Arch_MTime(GNode *);
time_t Arch_MemMTime(GNode *);
-void Arch_FindLib(GNode *, Lst);
+void Arch_FindLib(GNode *, SearchPath *);
Boolean Arch_LibOODate(GNode *);
-void Arch_Init(void);
-void Arch_End(void);
Boolean Arch_IsLib(GNode *);
/* compat.c */
-int CompatRunCommand(void *, void *);
-void Compat_Run(Lst);
-int Compat_Make(void *, void *);
+int Compat_RunCommand(const char *, GNode *);
+void Compat_Run(GNodeList *);
+void Compat_Make(GNode *, GNode *);
/* cond.c */
-struct If;
-CondEvalResult Cond_EvalExpression(const struct If *, char *, Boolean *, int, Boolean);
-CondEvalResult Cond_Eval(char *);
+CondEvalResult Cond_EvalCondition(const char *, Boolean *);
+CondEvalResult Cond_EvalLine(const char *);
void Cond_restore_depth(unsigned int);
unsigned int Cond_save_depth(void);
/* for.c */
-int For_Eval(char *);
-int For_Accum(char *);
+int For_Eval(const char *);
+Boolean For_Accum(const char *);
void For_Run(int);
/* job.c */
@@ -114,35 +114,52 @@ void Error(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
void Punt(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;
void DieHorribly(void) MAKE_ATTR_DEAD;
-int PrintAddr(void *, void *);
void Finish(int) MAKE_ATTR_DEAD;
int eunlink(const char *);
-void execError(const char *, const char *);
+void execDie(const char *, const char *);
char *getTmpdir(void);
Boolean s2Boolean(const char *, Boolean);
Boolean getBoolean(const char *, Boolean);
char *cached_realpath(const char *, char *);
/* parse.c */
-void Parse_Error(int, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
-Boolean Parse_IsVar(char *);
-void Parse_DoVar(char *, GNode *);
-void Parse_AddIncludeDir(char *);
-void Parse_File(const char *, int);
void Parse_Init(void);
void Parse_End(void);
-void Parse_SetInput(const char *, int, int, char *(*)(void *, size_t *), void *);
-Lst Parse_MainName(void);
+
+typedef enum VarAssignOp {
+ VAR_NORMAL, /* = */
+ VAR_SUBST, /* := */
+ VAR_SHELL, /* != or :sh= */
+ VAR_APPEND, /* += */
+ VAR_DEFAULT /* ?= */
+} VarAssignOp;
+
+typedef struct VarAssign {
+ char *varname; /* unexpanded */
+ VarAssignOp op;
+ const char *value; /* unexpanded */
+} VarAssign;
+
+typedef char *(*NextBufProc)(void *, size_t *);
+
+void Parse_Error(ParseErrorLevel, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3);
+Boolean Parse_IsVar(const char *, VarAssign *out_var);
+void Parse_DoVar(VarAssign *, GNode *);
+void Parse_AddIncludeDir(const char *);
+void Parse_File(const char *, int);
+void Parse_SetInput(const char *, int, int, NextBufProc, void *);
+GNodeList *Parse_MainName(void);
+int Parse_GetFatals(void);
/* str.c */
-typedef struct {
+typedef struct Words {
char **words;
size_t len;
void *freeIt;
} Words;
Words Str_Words(const char *, Boolean);
-static inline void MAKE_ATTR_UNUSED
+static inline MAKE_ATTR_UNUSED void
Words_Free(Words w) {
free(w.words);
free(w.freeIt);
@@ -151,7 +168,6 @@ Words_Free(Words w) {
char *str_concat2(const char *, const char *);
char *str_concat3(const char *, const char *, const char *);
char *str_concat4(const char *, const char *, const char *, const char *);
-char *Str_FindSubstring(const char *, const char *);
Boolean Str_Match(const char *, const char *);
#ifndef HAVE_STRLCPY
@@ -160,69 +176,134 @@ size_t strlcpy(char *, const char *, size_t);
#endif
/* suff.c */
+void Suff_Init(void);
+void Suff_End(void);
+
void Suff_ClearSuffixes(void);
-Boolean Suff_IsTransform(char *);
-GNode *Suff_AddTransform(char *);
-int Suff_EndTransform(void *, void *);
+Boolean Suff_IsTransform(const char *);
+GNode *Suff_AddTransform(const char *);
+void Suff_EndTransform(GNode *);
void Suff_AddSuffix(const char *, GNode **);
-Lst Suff_GetPath(char *);
+SearchPath *Suff_GetPath(const char *);
void Suff_DoPaths(void);
-void Suff_AddInclude(char *);
+void Suff_AddInclude(const char *);
void Suff_AddLib(const char *);
void Suff_FindDeps(GNode *);
-Lst Suff_FindPath(GNode *);
-void Suff_SetNull(char *);
-void Suff_Init(void);
-void Suff_End(void);
+SearchPath *Suff_FindPath(GNode *);
+void Suff_SetNull(const char *);
void Suff_PrintAll(void);
/* targ.c */
void Targ_Init(void);
void Targ_End(void);
+
void Targ_Stats(void);
-Lst Targ_List(void);
+GNodeList *Targ_List(void);
GNode *Targ_NewGN(const char *);
-GNode *Targ_FindNode(const char *, int);
-Lst Targ_FindList(Lst, int);
+GNode *Targ_FindNode(const char *);
+GNode *Targ_GetNode(const char *);
+GNode *Targ_NewInternalNode(const char *);
+GNode *Targ_GetEndNode(void);
+GNodeList *Targ_FindList(StringList *);
Boolean Targ_Ignore(GNode *);
Boolean Targ_Silent(GNode *);
Boolean Targ_Precious(GNode *);
void Targ_SetMain(GNode *);
-int Targ_PrintCmd(void *, void *);
-int Targ_PrintNode(void *, void *);
+void Targ_PrintCmds(GNode *);
+void Targ_PrintNode(GNode *, int);
+void Targ_PrintNodes(GNodeList *, int);
char *Targ_FmtTime(time_t);
void Targ_PrintType(int);
void Targ_PrintGraph(int);
void Targ_Propagate(void);
/* var.c */
+void Var_Init(void);
+void Var_End(void);
-typedef enum {
+typedef enum VarEvalFlags {
+ VARE_NONE = 0,
/* Treat undefined variables as errors. */
VARE_UNDEFERR = 0x01,
/* Expand and evaluate variables during parsing. */
VARE_WANTRES = 0x02,
+ /* In an assignment using the ':=' operator, keep '$$' as '$$' instead
+ * of reducing it to a single '$'. */
VARE_ASSIGN = 0x04
} VarEvalFlags;
-typedef enum {
+typedef enum VarSet_Flags {
VAR_NO_EXPORT = 0x01, /* do not export */
/* Make the variable read-only. No further modification is possible,
* except for another call to Var_Set with the same flag. */
VAR_SET_READONLY = 0x02
} VarSet_Flags;
+/* The state of error handling returned by Var_Parse.
+ *
+ * As of 2020-09-13, this bitset looks quite bloated,
+ * with all the constants doubled.
+ *
+ * Its purpose is to first document the existing behavior,
+ * and then migrate away from the SILENT constants, step by step,
+ * as these are not suited for reliable, consistent error handling
+ * and reporting. */
+typedef enum VarParseResult {
+
+ /* Both parsing and evaluation succeeded. */
+ VPR_OK = 0x0000,
+
+ /* See if a message has already been printed for this error. */
+ VPR_ANY_MSG = 0x0001,
+
+ /* Parsing failed.
+ * No error message has been printed yet.
+ * Deprecated, migrate to VPR_PARSE_MSG instead. */
+ VPR_PARSE_SILENT = 0x0002,
+
+ /* Parsing failed.
+ * An error message has already been printed. */
+ VPR_PARSE_MSG = VPR_PARSE_SILENT | VPR_ANY_MSG,
+
+ /* Parsing succeeded.
+ * During evaluation, VARE_UNDEFERR was set and there was an undefined
+ * variable.
+ * No error message has been printed yet.
+ * Deprecated, migrate to VPR_UNDEF_MSG instead. */
+ VPR_UNDEF_SILENT = 0x0004,
+
+ /* Parsing succeeded.
+ * During evaluation, VARE_UNDEFERR was set and there was an undefined
+ * variable.
+ * An error message has already been printed. */
+ VPR_UNDEF_MSG = VPR_UNDEF_SILENT | VPR_ANY_MSG,
+
+ /* Parsing succeeded.
+ * Evaluation failed.
+ * No error message has been printed yet.
+ * Deprecated, migrate to VPR_EVAL_MSG instead. */
+ VPR_EVAL_SILENT = 0x0006,
+
+ /* Parsing succeeded.
+ * Evaluation failed.
+ * An error message has already been printed. */
+ VPR_EVAL_MSG = VPR_EVAL_SILENT | VPR_ANY_MSG,
+
+ /* The exact error handling status is not known yet.
+ * Deprecated, migrate to VPR_OK or any VPE_*_MSG instead. */
+ VPR_UNKNOWN = 0x0008
+} VarParseResult;
void Var_Delete(const char *, GNode *);
void Var_Set(const char *, const char *, GNode *);
void Var_Set_with_flags(const char *, const char *, GNode *, VarSet_Flags);
void Var_Append(const char *, const char *, GNode *);
Boolean Var_Exists(const char *, GNode *);
-const char *Var_Value(const char *, GNode *, char **);
-const char *Var_Parse(const char *, GNode *, VarEvalFlags, int *, void **);
-char *Var_Subst(const char *, GNode *, VarEvalFlags);
-void Var_Init(void);
-void Var_End(void);
+const char *Var_Value(const char *, GNode *, void **);
+const char *Var_ValueDirect(const char *, GNode *);
+VarParseResult Var_Parse(const char **, GNode *, VarEvalFlags,
+ const char **, void **);
+VarParseResult Var_Subst(const char *, GNode *, VarEvalFlags, char **);
void Var_Stats(void);
void Var_Dump(GNode *);
void Var_ExportVars(void);
@@ -230,4 +311,5 @@ void Var_Export(const char *, Boolean);
void Var_UnExport(const char *);
/* util.c */
-void (*bmake_signal(int, void (*)(int)))(int);
+typedef void (*SignalProc)(int);
+SignalProc bmake_signal(int, SignalProc);