Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
C-datadec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Duncan White
C-datadec
Commits
261b7c79
Commit
261b7c79
authored
35 years ago
by
dcw
Browse files
Options
Downloads
Patches
Plain Diff
rewrote arg processing a bit,
added verbose flag.
parent
05647625
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
datadec.c
+47
-15
47 additions, 15 deletions
datadec.c
with
47 additions
and
15 deletions
datadec.c
+
47
−
15
View file @
261b7c79
...
...
@@ -10,11 +10,10 @@
*
* This program builds C data declarations, construction functions
* and print functions from a series of HOPE/Miranda style recursive
* data declarations. (with hints on printing)
* data declarations. (with
optional
hints on printing)
*
* The output produced is placed in pair of files
* ( x.c and x.h ) which together form a module provided the
* relevent data types.
* The output produced is placed in pair of files (eg. x.c and x.h )
* which together form a module provided the relevent data types.
*/
#include
<dcw.h>
...
...
@@ -23,19 +22,39 @@
#include
"parser.h"
#define MUSTBE(b) ASSERT(b,("Usage: datadec [-v] outfile [infile]\n"))
#define NEED_ANOTHER_ARG MUSTBE( IS_ANOTHER_ARG )
#define REQUIRE_NO_MORE_ARGS MUSTBE( argc == arg )
#define IS_ANOTHER_ARG (argc > arg)
main
(
argc
,
argv
)
int
argc
;
char
**
argv
;
{
FILE
*
infile
,
*
cfile
,
*
hfile
;
char
inname
[
256
],
tempname
[
256
];
FILE
*
cfile
,
*
hfile
;
char
tempname
[
256
];
declnlist
declns
;
int
len
;
char
*
basename
;
BOOL
verbose
;
int
arg
;
ASSERT
(
argc
==
2
||
argc
==
3
,
(
"Usage: datadec outfile [infile]
\n
"
)
);
arg
=
1
;
NEED_ANOTHER_ARG
;
verbose
=
FALSE
;
if
(
strcmp
(
argv
[
arg
],
"-v"
)
==
0
)
{
arg
++
;
verbose
=
TRUE
;
}
basename
=
argv
[
1
];
NEED_ANOTHER_ARG
;
basename
=
argv
[
arg
++
];
len
=
strlen
(
basename
);
if
(
!
strcmp
(
basename
+
len
-
2
,
".c"
)
)
{
if
(
!
strcmp
(
basename
+
len
-
2
,
".c"
)
)
{
basename
[
len
-
2
]
=
'\0'
;
}
...
...
@@ -47,16 +66,29 @@ main( argc, argv ) int argc; char **argv;
hfile
=
fopen
(
tempname
,
"w"
);
ASSERT
(
hfile
!=
NULL
,
(
"datadec: can't create '%s'
\n
"
,
tempname
)
);
if
(
argc
==
3
)
{
lexfile
=
fopen
(
argv
[
2
],
"r"
);
if
(
IS_ANOTHER_ARG
)
{
lexfile
=
fopen
(
argv
[
arg
],
"r"
);
ASSERT
(
lexfile
!=
NULL
,
(
"datadec: can't open '%s'
\n
"
,
argv
[
2
])
);
(
"datadec: can't open '%s'
\n
"
,
argv
[
arg
])
);
arg
++
;
}
else
{
lexfile
=
stdin
;
}
ASSERT
(
parse_declns
(
&
declns
),
(
"datadec: can't parse input properly
\n
"
)
);
make_declns
(
declns
,
cfile
,
hfile
,
basename
);
REQUIRE_NO_MORE_ARGS
;
if
(
parse_declns
(
&
declns
)
)
{
if
(
verbose
)
{
printf
(
"parsed declns: they are:
\n\n
"
);
print_declnlist
(
declns
);
}
make_declns
(
declns
,
cfile
,
hfile
,
basename
);
}
else
{
fprintf
(
stderr
,
"datadec: can't parse input properly
\n
"
);
}
fclose
(
cfile
);
fclose
(
hfile
);
exit
(
0
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment