Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
codes
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
38
Issues
38
List
Boards
Labels
Milestones
Merge Requests
8
Merge Requests
8
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
codes
codes
Commits
a4cc1dfe
Commit
a4cc1dfe
authored
Mar 06, 2015
by
Jonathan Jenkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bye-bye "tools" files
parent
1436b67e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
121 deletions
+30
-121
codes/tools.h
codes/tools.h
+0
-56
src/Makefile.subdir
src/Makefile.subdir
+0
-3
src/modelconfig/configglue.c
src/modelconfig/configglue.c
+5
-5
src/modelconfig/configlex.l
src/modelconfig/configlex.l
+0
-1
src/modelconfig/configparser.y
src/modelconfig/configparser.y
+4
-5
src/modelconfig/configstoreadapter.c
src/modelconfig/configstoreadapter.c
+11
-2
src/modelconfig/txt_configfile.c
src/modelconfig/txt_configfile.c
+10
-11
src/util/tools.c
src/util/tools.c
+0
-38
No files found.
codes/tools.h
deleted
100644 → 0
View file @
1436b67e
/*
* Copyright (C) 2013 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#ifndef SRC_COMMON_UTIL_TOOLS_H
#define SRC_COMMON_UTIL_TOOLS_H
#ifdef UNUSED
#elif defined(__GNUC__)
# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
#elif defined(__LCLINT__)
# define UNUSED(x)
/*@unused@*/
x
#else
# define UNUSED(x) x
#endif
/* UNUSED */
#define codesmin(a,b) ((a)<(b) ? (a):(b))
#define codesmax(a,b) ((a)>(b) ? (a):(b))
void
always_assert_error
(
const
char
*
expr
,
const
char
*
file
,
int
lineno
);
#define ALWAYS_ASSERT(a) if (!(a)) always_assert_error(#a,__FILE__, __LINE__);
#define ARRAY_SIZEOF(a) (sizeof(a)/sizeof(a[0]))
char
*
safe_strncpy
(
char
*
buf
,
const
char
*
source
,
unsigned
int
bufsize
);
#define CODES_FLAG_ISSET(mode_, flag_) ((mode_ & flag_) != 0)
#define CODES_FLAG_SET(mode_, flag_, branch_) \
do \
{ \
mode_ = mode_ | flag_; \
branch_ = 1; \
}while(0)
#define CODES_FLAG_SET_RC(mode_, flag_, branch_) \
do \
{ \
if(branch_) \
{ \
mode_ = mode_ & (~flag_); \
} \
}while(0)
#endif
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
src/Makefile.subdir
View file @
a4cc1dfe
...
...
@@ -50,7 +50,6 @@ nobase_include_HEADERS = \
codes/CodesIOKernelTypes.h
\
codes/codeslexer.h
\
codes/txt_configfile.h
\
codes/tools.h
\
codes/codeslogging.h
\
codes/timeline.h
\
codes/codesparser.h
\
...
...
@@ -97,8 +96,6 @@ src_libcodes_base_a_SOURCES = \
src/modelconfig/configstoreadapter.c
\
codes/txt_configfile.h
\
src/modelconfig/txt_configfile.c
\
codes/tools.h
\
src/util/tools.c
\
src/util/codes-callbacks.h
\
src/util/codes-callbacks.c
\
src/util/codes_mapping.c
\
...
...
src/modelconfig/configglue.c
View file @
a4cc1dfe
...
...
@@ -4,10 +4,10 @@
*
*/
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "configglue.h"
#include "codes/tools.h"
int
cfgp_lex_error
(
ParserParams
*
p
,
int
lineno
,
int
colno
,
const
char
*
msg
)
{
...
...
@@ -68,17 +68,17 @@ int cfgp_parse_ok (const ParserParams * p, char * buf, int bufsize)
{
/* doublecheck that if an error string is present, the error code is also
* set */
ALWAYS_ASSERT
(
!
p
->
lexer_error_string
||
p
->
lexer_error_code
);
ALWAYS_ASSERT
(
!
p
->
parser_error_string
||
p
->
parser_error_code
);
assert
(
!
p
->
lexer_error_string
||
p
->
lexer_error_code
);
assert
(
!
p
->
parser_error_string
||
p
->
parser_error_code
);
if
(
p
->
lexer_error_code
)
{
s
afe_s
trncpy
(
buf
,
p
->
lexer_error_string
,
bufsize
);
strncpy
(
buf
,
p
->
lexer_error_string
,
bufsize
);
return
0
;
}
if
(
p
->
parser_error_code
)
{
s
afe_s
trncpy
(
buf
,
p
->
parser_error_string
,
bufsize
);
strncpy
(
buf
,
p
->
parser_error_string
,
bufsize
);
return
0
;
}
return
1
;
...
...
src/modelconfig/configlex.l
View file @
a4cc1dfe
...
...
@@ -3,7 +3,6 @@
#include <string.h>
#include "src/modelconfig/configglue.h"
#include "src/modelconfig/configparser.h"
#include "codes/tools.h"
#define YY_EXTRA_TYPE ParserParams *
...
...
src/modelconfig/configparser.y
View file @
a4cc1dfe
...
...
@@ -18,7 +18,6 @@
#include <assert.h>
#include "src/modelconfig/configglue.h"
#include "codes/tools.h"
#if defined __GNUC__
#pragma GCC diagnostic ignored "-Wunused-parameter"
...
...
@@ -116,7 +115,7 @@ singlekey: IDENTIFIER EQUAL_TOKEN LITERAL_STRING SEMICOLUMN {
multikeynonzero: KOMMA LITERAL_STRING {
param->keyvals[param->count++] = strdup ($<string_buf>2);
ALWAYS_ASSERT
(param->count < param->maxsize);
assert
(param->count < param->maxsize);
}
multikeyentry : multikeynonzero multikeyentry | ;
...
...
@@ -129,7 +128,7 @@ multikeyinit : /* empty */ {
multikeystart : LITERAL_STRING {
param->keyvals[param->count++] = strdup ($<string_buf>1);
ALWAYS_ASSERT
(param->count < param->maxsize);
assert
(param->count < param->maxsize);
}
/* this can probably be simplified */
...
...
@@ -159,7 +158,7 @@ opt_semicolumn: SEMICOLUMN | ;
subsection_openaction: IDENTIFIER OPENSECTION
{
SectionHandle newsection;
ALWAYS_ASSERT(param->stacktop < ARRAY_SIZEOF(param->sectionstack
));
assert(param->stacktop < sizeof(param->sectionstack)/sizeof(param->sectionstack[0]
));
cf_createSection (param->configfile,
param->sectionstack[param->stacktop], $1,
...
...
@@ -172,7 +171,7 @@ subsection_openaction: IDENTIFIER OPENSECTION
subsection_closeaction: CLOSESECTION opt_semicolumn
{
ALWAYS_ASSERT
(param->stacktop > 0);
assert
(param->stacktop > 0);
SectionHandle old = param->sectionstack[param->stacktop--];
cf_closeSection (param->configfile, old);
};
...
...
src/modelconfig/configstoreadapter.c
View file @
a4cc1dfe
...
...
@@ -15,9 +15,18 @@
#include <string.h>
#include "configstoreadapter.h"
#include "codes/tools.h"
#include "configstore.h"
/* unused attribute is only used here, so use directly in source */
#ifdef UNUSED
#elif defined(__GNUC__)
# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
#elif defined(__LCLINT__)
# define UNUSED(x)
/*@unused@*/
x
#else
# define UNUSED(x) x
#endif
/* UNUSED */
static
int
cfsa_getKey
(
void
*
handle
,
SectionHandle
section
,
const
char
*
name
,
char
*
buf
,
size_t
bufsize
)
{
...
...
@@ -53,7 +62,7 @@ static int cfsa_getKey (void * handle, SectionHandle section, const char * name
if
(
!
dcount
)
{
ALWAYS_ASSERT
(
buf
);
assert
(
buf
);
*
buf
=
0
;
ret
=
0
;
/* tmp was not modified no need to free */
...
...
src/modelconfig/txt_configfile.c
View file @
a4cc1dfe
...
...
@@ -7,7 +7,6 @@
#include <assert.h>
#include <stdio.h>
#include "codes/txt_configfile.h"
#include "codes/tools.h"
#include "configglue.h"
#include "src/modelconfig/configparser.h"
#include "src/modelconfig/configlex.h"
...
...
@@ -112,7 +111,7 @@ static int dump_section (FILE * f, ConfigHandle h, SectionHandle s, unsigned
if
(
ret
<
0
)
goto
fail
;
ALWAYS_ASSERT
(
sectionsize
==
count
);
assert
(
sectionsize
==
count
);
for
(
i
=
0
;
i
<
count
;
++
i
)
{
...
...
@@ -133,8 +132,8 @@ fail:
int
txtfile_writeConfig
(
ConfigHandle
cf
,
SectionHandle
h
,
FILE
*
f
,
char
**
err
)
{
int
ret
;
ALWAYS_ASSERT
(
err
);
ALWAYS_ASSERT
(
f
);
assert
(
err
);
assert
(
f
);
*
err
=
0
;
...
...
@@ -155,7 +154,7 @@ ConfigHandle txtfile_openStream (FILE * f, char ** err)
int
reject
;
char
buf
[
512
];
ALWAYS_ASSERT
(
err
);
assert
(
err
);
*
err
=
0
;
...
...
@@ -179,12 +178,12 @@ ConfigHandle txtfile_openStream (FILE * f, char ** err)
/* either we have a valid confighandle or we have a parser error... */
/* not true: we can have a partial config tree */
//
ALWAYS_ASSERT
((p.error_code || p.configfile) && (!p.error_code || !p.configfile));
//
assert
((p.error_code || p.configfile) && (!p.error_code || !p.configfile));
/* If ther parser failed we need to have an error code */
ALWAYS_ASSERT
(
!
reject
||
p
.
parser_error_code
||
p
.
lexer_error_code
);
ALWAYS_ASSERT
(
!
p
.
lexer_error_string
||
p
.
lexer_error_code
);
ALWAYS_ASSERT
(
!
p
.
parser_error_string
||
p
.
parser_error_code
);
assert
(
!
reject
||
p
.
parser_error_code
||
p
.
lexer_error_code
);
assert
(
!
p
.
lexer_error_string
||
p
.
lexer_error_code
);
assert
(
!
p
.
parser_error_string
||
p
.
parser_error_code
);
if
(
!
cfgp_parse_ok
(
&
p
,
buf
,
sizeof
(
buf
)))
{
...
...
@@ -192,8 +191,8 @@ ConfigHandle txtfile_openStream (FILE * f, char ** err)
}
else
{
ALWAYS_ASSERT
(
!
p
.
parser_error_string
);
ALWAYS_ASSERT
(
!
p
.
lexer_error_string
);
assert
(
!
p
.
parser_error_string
);
assert
(
!
p
.
lexer_error_string
);
if
(
err
)
*
err
=
0
;
}
...
...
src/util/tools.c
deleted
100644 → 0
View file @
1436b67e
/*
* Copyright (C) 2013 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "codes/tools.h"
char
*
safe_strncpy
(
char
*
buf
,
const
char
*
source
,
unsigned
int
size
)
{
ALWAYS_ASSERT
(
buf
);
ALWAYS_ASSERT
(
source
);
ALWAYS_ASSERT
(
size
);
strncpy
(
buf
,
source
,
size
);
/* size will be >0 (assert above); */
buf
[
size
-
1
]
=
0
;
return
buf
;
}
void
always_assert_error
(
const
char
*
expr
,
const
char
*
file
,
int
lineno
)
{
fprintf
(
stderr
,
"Assertion '%s' failed (%s:%i)!
\n
"
,
expr
,
file
,
lineno
);
abort
();
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment