Skip to content

Commit

Permalink
{c,cpp}/*: rename headers
Browse files Browse the repository at this point in the history
We used to risk shadowing standard headers, so the old names were given with that in mind. Now that we prefix all our headers with xph/, we can "shadow" them.
  • Loading branch information
XPhyro committed Jan 21, 2024
1 parent 880feba commit c1d3b50
Show file tree
Hide file tree
Showing 62 changed files with 516 additions and 517 deletions.
4 changes: 2 additions & 2 deletions src/.make
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ CFLAGS="-O${o:-3} $g $ndebug -std=c99 -pedantic \
-ffp-contract=on -fassociative-math -ffast-math -flto \
$C_INCLUDE_FLAGS"
CLDFLAGS=""
C_INCLUDE_PATH="$PWD/c/include:$rootdir/lib/hedley"
C_INCLUDE_PATH="$rootdir/lib/hedley:$C_INCLUDE_PATH"
export C_INCLUDE_PATH

CXX="g++"
Expand All @@ -1155,7 +1155,7 @@ CXXFLAGS="-O${o:-3} $g $ndebug -std=c++2b \
-fpermissive -fvtable-verify=none \
$CXX_INCLUDE_FLAGS"
CXXLDFLAGS=""
CPLUS_INCLUDE_PATH="$PWD/cpp/include:$PWD/c/include:$rootdir/lib/hedley:$rootdir/lib/pstreams"
CPLUS_INCLUDE_PATH="$rootdir/lib/hedley:$rootdir/lib/pstreams:$CPLUS_INCLUDE_PATH"
export CPLUS_INCLUDE_PATH

C_CPPCHECK_SUPPRESS="--suppress=variableScope"
Expand Down
10 changes: 5 additions & 5 deletions src/c/include/dbutil.h → src/c/include/database.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HEADER_SCRIPTS_C_DBUTIL_
#define HEADER_SCRIPTS_C_DBUTIL_
#ifndef HEADER_SCRIPTS_C_DATABASE_
#define HEADER_SCRIPTS_C_DATABASE_

#include <assert.h>
#include <errno.h>
Expand All @@ -15,8 +15,8 @@
#include <hedley.h>

#include "meta.h"
#include "strutil.h"
#include "sysutil.h"
#include "string.h"
#include "sys.h"

const char *const db_scriptsprefix = "/scripts/";
const char *const db_locksprefix = "/locks/";
Expand Down Expand Up @@ -254,4 +254,4 @@ bool ulckdb(const char *hash, lckdb_t type)
return ret;
}

#endif /* ifndef HEADER_SCRIPTS_C_DBUTIL_ */
#endif /* ifndef HEADER_SCRIPTS_C_DATABASE_ */
6 changes: 3 additions & 3 deletions src/c/include/exec_info.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HEADER_SCRIPTS_C_EXECINFO_
#define HEADER_SCRIPTS_C_EXECINFO_
#ifndef HEADER_SCRIPTS_C_EXEC_INFO_
#define HEADER_SCRIPTS_C_EXEC_INFO_

#include <stdio.h>
#include <string.h>
Expand All @@ -24,4 +24,4 @@ void init_exec_info(int argc, char **argv)
}
}

#endif /* ifndef HEADER_SCRIPTS_C_EXECINFO_ */
#endif /* ifndef HEADER_SCRIPTS_C_EXEC_INFO_ */
6 changes: 3 additions & 3 deletions src/c/include/ioutil.h → src/c/include/io.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HEADER_SCRIPTS_C_IOUTIL_
#define HEADER_SCRIPTS_C_IOUTIL_
#ifndef HEADER_SCRIPTS_C_IO_
#define HEADER_SCRIPTS_C_IO_

#include <stdio.h>
#include <sys/types.h>
Expand Down Expand Up @@ -31,4 +31,4 @@ char *getstr(int argc, char *argv[], int delim)
}
#endif /* #if _POSIX_C_SOURCE >= 200809L */

#endif /* ifndef HEADER_SCRIPTS_C_IOUTIL_ */
#endif /* ifndef HEADER_SCRIPTS_C_IO_ */
6 changes: 3 additions & 3 deletions src/c/include/mathutil.h → src/c/include/math.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HEADER_SCRIPTS_C_MATHUTIL_
#define HEADER_SCRIPTS_C_MATHUTIL_
#ifndef HEADER_SCRIPTS_C_MATH_
#define HEADER_SCRIPTS_C_MATH_

#include <stdbool.h>

Expand All @@ -23,4 +23,4 @@ bool approxeqf(float x, float y)
return approxzerof(x - y);
}

#endif /* ifndef HEADER_SCRIPTS_C_MATHUTIL_ */
#endif /* ifndef HEADER_SCRIPTS_C_MATH_ */
6 changes: 3 additions & 3 deletions src/c/include/paramutil.h → src/c/include/param.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HEADER_SCRIPTS_C_PARAMUTIL_
#define HEADER_SCRIPTS_C_PARAMUTIL_
#ifndef HEADER_SCRIPTS_C_PARAM_
#define HEADER_SCRIPTS_C_PARAM_

#define STRINGIFY_IMPL_(VAL) #VAL
#define STRINGIFY(VAL) STRINGIFY_IMPL_(VAL)
Expand All @@ -8,4 +8,4 @@

extern int _iso_c_forbids_an_empty_translation_unit;

#endif /* ifndef HEADER_SCRIPTS_C_PARAMUTIL_ */
#endif /* ifndef HEADER_SCRIPTS_C_PARAM_ */
6 changes: 3 additions & 3 deletions src/c/include/stdutil.h → src/c/include/stdlib.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HEADER_SCRIPTS_C_STDUTIL_
#define HEADER_SCRIPTS_C_STDUTIL_
#ifndef HEADER_SCRIPTS_C_STDLIB_
#define HEADER_SCRIPTS_C_STDLIB_

#include <errno.h>
#include <limits.h>
Expand Down Expand Up @@ -187,4 +187,4 @@ HEDLEY_MALLOC void *aaligned_alloc(size_t alignment, size_t size)
}
#endif /* ifdef _ISOC11_SOURCE */

#endif /* ifndef HEADER_SCRIPTS_C_STDUTIL_ */
#endif /* ifndef HEADER_SCRIPTS_C_STDLIB_ */
8 changes: 4 additions & 4 deletions src/c/include/strutil.h → src/c/include/string.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HEADER_SCRIPTS_C_STRUTIL_
#define HEADER_SCRIPTS_C_STRUTIL_
#ifndef HEADER_SCRIPTS_C_STRING_
#define HEADER_SCRIPTS_C_STRING_

#include <assert.h>
#include <ctype.h>
Expand All @@ -13,7 +13,7 @@

#include <hedley.h>

#include "stdutil.h"
#include "stdlib.h"

HEDLEY_MALLOC HEDLEY_ALWAYS_INLINE void *amallocset(size_t size, int c)
{
Expand Down Expand Up @@ -538,4 +538,4 @@ char *vstrcatbuf(char *buf, size_t bufsize, size_t n, ...)
return o;
}

#endif /* ifndef HEADER_SCRIPTS_C_STRUTIL_ */
#endif /* ifndef HEADER_SCRIPTS_C_STRING_ */
8 changes: 4 additions & 4 deletions src/c/include/sysutil.h → src/c/include/sys.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HEADER_SCRIPTS_C_SYSUTIL_
#define HEADER_SCRIPTS_C_SYSUTIL_
#ifndef HEADER_SCRIPTS_C_SYS_
#define HEADER_SCRIPTS_C_SYS_

#include <assert.h>
#include <fcntl.h>
Expand All @@ -13,7 +13,7 @@

#include <hedley.h>

#include "strutil.h"
#include "string.h"

/* path is modified in the process, but restored to original */
void rmkparent(char *path, mode_t mode)
Expand Down Expand Up @@ -181,4 +181,4 @@ HEDLEY_MALLOC char *dirslash(const char *path)
return s;
}

#endif /* ifndef HEADER_SCRIPTS_C_SYSUTIL_ */
#endif /* ifndef HEADER_SCRIPTS_C_SYS_ */
2 changes: 1 addition & 1 deletion src/c/util/core/addentropy.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <sys/param.h>
#include <unistd.h>

#include <xph/stdutil.h>
#include <xph/stdlib.h>

int main(void)
{
Expand Down
4 changes: 2 additions & 2 deletions src/c/util/core/afgrep.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <string.h>
#include <unistd.h>

#include <xph/stdutil.h>
#include <xph/strutil.h>
#include <xph/stdlib.h>
#include <xph/string.h>

#define EXECNAME "afgrep"
#define DIE(...) \
Expand Down
4 changes: 2 additions & 2 deletions src/c/util/core/bpersec.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <unistd.h>

#include <xph/exec_info.h>
#include <xph/paramutil.h>
#include <xph/stdutil.h>
#include <xph/param.h>
#include <xph/stdlib.h>

DEFINE_EXEC_INFO()

Expand Down
4 changes: 2 additions & 2 deletions src/c/util/core/expandpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <sys/types.h>
#include <unistd.h>

#include <xph/ioutil.h>
#include <xph/stdutil.h>
#include <xph/io.h>
#include <xph/stdlib.h>

#define DIE(...) \
{ \
Expand Down
2 changes: 1 addition & 1 deletion src/c/util/core/fmapc.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <sys/types.h>
#include <unistd.h>

#include <xph/stdutil.h>
#include <xph/stdlib.h>

#define DIE(ERRMSG) \
{ \
Expand Down
4 changes: 2 additions & 2 deletions src/c/util/core/fmaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <sys/types.h>
#include <unistd.h>

#include <xph/stdutil.h>
#include <xph/strutil.h>
#include <xph/stdlib.h>
#include <xph/string.h>

#define DIE(ERRMSG) \
{ \
Expand Down
6 changes: 3 additions & 3 deletions src/c/util/core/lck.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include <time.h>
#include <unistd.h>

#include <xph/dbutil.h>
#include <xph/database.h>
#include <xph/exec_info.h>
#include <xph/stdutil.h>
#include <xph/strutil.h>
#include <xph/stdlib.h>
#include <xph/string.h>

DEFINE_EXEC_INFO()

Expand Down
2 changes: 1 addition & 1 deletion src/c/util/core/rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <sys/random.h>
#endif

#include <xph/stdutil.h>
#include <xph/stdlib.h>

#define EXECNAME "rand"

Expand Down
4 changes: 2 additions & 2 deletions src/c/util/core/scrolls.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include <unistd.h>

#include <xph/exec_info.h>
#include <xph/paramutil.h>
#include <xph/stdutil.h>
#include <xph/param.h>
#include <xph/stdlib.h>

DEFINE_EXEC_INFO()

Expand Down
4 changes: 2 additions & 2 deletions src/c/util/core/slash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <stdio.h>

#include <xph/ioutil.h>
#include <xph/sysutil.h>
#include <xph/io.h>
#include <xph/sys.h>

int main(int argc, char *argv[])
{
Expand Down
4 changes: 2 additions & 2 deletions src/c/util/core/stest.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

#include <magic.h>

#include <xph/ioutil.h>
#include <xph/strutil.h>
#include <xph/io.h>
#include <xph/string.h>

#ifndef S_ISVTX
#define S_ISVTX 01000
Expand Down
6 changes: 3 additions & 3 deletions src/c/util/core/sumsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include <unistd.h>

#include <xph/exec_info.h>
#include <xph/ioutil.h>
#include <xph/stdutil.h>
#include <xph/strutil.h>
#include <xph/io.h>
#include <xph/stdlib.h>
#include <xph/string.h>

#include <hedley.h>

Expand Down
6 changes: 3 additions & 3 deletions src/c/util/core/unexpandpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include <sys/types.h>
#include <unistd.h>

#include <xph/ioutil.h>
#include <xph/stdutil.h>
#include <xph/strutil.h>
#include <xph/io.h>
#include <xph/stdlib.h>
#include <xph/string.h>

#define NUSERSINIT 10

Expand Down
2 changes: 1 addition & 1 deletion src/c/util/core/usbctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <unistd.h>

#include <xph/exec_info.h>
#include <xph/stdutil.h>
#include <xph/stdlib.h>

DEFINE_EXEC_INFO()

Expand Down
2 changes: 1 addition & 1 deletion src/c/util/core/wordexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdlib.h>
#include <wordexp.h>

#include <xph/ioutil.h>
#include <xph/io.h>

int safewordexp(const char *restrict s, wordexp_t *restrict result, int flags)
{
Expand Down
2 changes: 1 addition & 1 deletion src/c/util/dev/checkers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <sys/param.h>
#include <unistd.h>

#include <xph/strutil.h>
#include <xph/string.h>

int main(int argc, char *argv[])
{
Expand Down
2 changes: 1 addition & 1 deletion src/c/util/io/fputsn.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>

#include <xph/stdutil.h>
#include <xph/stdlib.h>

#define EXECNAME "fputsn"
#define DIE(ERRMSG) \
Expand Down
2 changes: 1 addition & 1 deletion src/c/util/io/putsn.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>

#include <xph/stdutil.h>
#include <xph/stdlib.h>

#define EXECNAME "putsn"
#define DIE(ERRMSG) \
Expand Down
2 changes: 1 addition & 1 deletion src/c/util/math/rgb24togray.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <unistd.h>

#include <xph/exec_info.h>
#include <xph/strutil.h>
#include <xph/string.h>

#include <hedley.h>

Expand Down
4 changes: 2 additions & 2 deletions src/c/util/math/sumbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <stdlib.h>
#include <unistd.h>

#include <xph/ioutil.h>
#include <xph/stdutil.h>
#include <xph/io.h>
#include <xph/stdlib.h>

#define EXECNAME "sumbase"

Expand Down
7 changes: 3 additions & 4 deletions src/c/util/other/fizzbuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
#include <string.h>
#include <unistd.h>

#include <stdutil.h>
#include <strutil.h>

#include <xph/exec_info.h>
#include <xph/paramutil.h>
#include <xph/param.h>
#include <xph/stdlib.h>
#include <xph/string.h>

DEFINE_EXEC_INFO()

Expand Down
6 changes: 3 additions & 3 deletions src/c/util/pathfinding/getpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include <sys/param.h>
#include <unistd.h>

#include <xph/stdutil.h>
#include <xph/sysutil.h>

#include <hedley.h>

#include <xph/stdlib.h>
#include <xph/sys.h>

#define EXECNAME "getpath"

#define DIE(...) die(shellinit, argc, argv, __VA_ARGS__)
Expand Down
Loading

0 comments on commit c1d3b50

Please sign in to comment.