Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
pikelang
pike
Commits
39dc6c27
Commit
39dc6c27
authored
24 years ago
by
Fredrik Hübinette (Hubbe)
Browse files
Options
Downloads
Patches
Plain Diff
varargs macros now implemented (same syntax as GCC varargs macros)
Rev: src/cpp.c:1.65 Rev: src/preprocessor.h:1.24
parent
cc82fbb2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cpp.c
+4
-2
4 additions, 2 deletions
src/cpp.c
src/preprocessor.h
+22
-2
22 additions, 2 deletions
src/preprocessor.h
with
26 additions
and
4 deletions
src/cpp.c
+
4
−
2
View file @
39dc6c27
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
\*/
\*/
/*
/*
* $Id: cpp.c,v 1.6
4
2000/06/
06 22:51:55
hubbe Exp $
* $Id: cpp.c,v 1.6
5
2000/06/
13 21:39:34
hubbe Exp $
*/
*/
#include
"global.h"
#include
"global.h"
#include
"stralloc.h"
#include
"stralloc.h"
...
@@ -84,7 +84,8 @@ struct define
...
@@ -84,7 +84,8 @@ struct define
magic_define_fun
magic
;
magic_define_fun
magic
;
int
args
;
int
args
;
int
num_parts
;
int
num_parts
;
int
inside
;
short
inside
;
short
varargs
;
struct
pike_string
*
first
;
struct
pike_string
*
first
;
struct
define_part
parts
[
1
];
struct
define_part
parts
[
1
];
};
};
...
@@ -138,6 +139,7 @@ static struct define *alloc_empty_define(struct pike_string *name, INT32 parts)
...
@@ -138,6 +139,7 @@ static struct define *alloc_empty_define(struct pike_string *name, INT32 parts)
def
->
magic
=
0
;
def
->
magic
=
0
;
def
->
args
=-
1
;
def
->
args
=-
1
;
def
->
inside
=
0
;
def
->
inside
=
0
;
def
->
varargs
=
0
;
def
->
num_parts
=
parts
;
def
->
num_parts
=
parts
;
def
->
first
=
0
;
def
->
first
=
0
;
def
->
link
.
s
=
name
;
def
->
link
.
s
=
name
;
...
...
This diff is collapsed.
Click to expand it.
src/preprocessor.h
+
22
−
2
View file @
39dc6c27
/*
/*
* $Id: preprocessor.h,v 1.2
3
2000/0
4/01 07:26:29
hubbe Exp $
* $Id: preprocessor.h,v 1.2
4
2000/0
6/13 21:39:34
hubbe Exp $
*
*
* Preprocessor template.
* Preprocessor template.
* Based on cpp.c 1.45
* Based on cpp.c 1.45
...
@@ -891,6 +891,12 @@ static INT32 lower_cpp(struct cpp *this,
...
@@ -891,6 +891,12 @@ static INT32 lower_cpp(struct cpp *this,
if
(
data
[
pos
]
==
')'
)
if
(
data
[
pos
]
==
')'
)
{
{
char
buffer
[
1024
];
char
buffer
[
1024
];
if
(
d
->
varargs
&&
arg
+
1
==
d
->
args
)
{
arguments
[
arg
].
arg
=
MKPCHARP
(
data
+
pos
,
SHIFT
);
arguments
[
arg
].
len
=
0
;
continue
;
}
sprintf
(
buffer
,
sprintf
(
buffer
,
"Too few arguments to macro %.950s, expected %d."
,
"Too few arguments to macro %.950s, expected %d."
,
d
->
link
.
s
->
str
,
d
->
args
);
d
->
link
.
s
->
str
,
d
->
args
);
...
@@ -928,8 +934,11 @@ static INT32 lower_cpp(struct cpp *this,
...
@@ -928,8 +934,11 @@ static INT32 lower_cpp(struct cpp *this,
pos
=
find_end_parenthesis
(
this
,
data
,
len
,
pos
);
pos
=
find_end_parenthesis
(
this
,
data
,
len
,
pos
);
continue
;
continue
;
case
','
:
if
(
d
->
varargs
&&
arg
+
1
==
d
->
args
)
continue
;
case
')'
:
case
')'
:
case
','
:
pos
--
;
pos
--
;
break
;
break
;
}
}
break
;
break
;
...
@@ -1584,6 +1593,7 @@ static INT32 lower_cpp(struct cpp *this,
...
@@ -1584,6 +1593,7 @@ static INT32 lower_cpp(struct cpp *this,
INT32
namestart
,
tmp3
,
nameend
,
argno
=-
1
;
INT32
namestart
,
tmp3
,
nameend
,
argno
=-
1
;
struct
define
*
def
;
struct
define
*
def
;
struct
svalue
*
partbase
,
*
argbase
=
Pike_sp
;
struct
svalue
*
partbase
,
*
argbase
=
Pike_sp
;
int
varargs
=
0
;
SKIPSPACE
();
SKIPSPACE
();
...
@@ -1615,6 +1625,8 @@ static INT32 lower_cpp(struct cpp *this,
...
@@ -1615,6 +1625,8 @@ static INT32 lower_cpp(struct cpp *this,
"Expecting comma in macro definition."
);
"Expecting comma in macro definition."
);
SKIPWHITE
();
SKIPWHITE
();
}
}
if
(
varargs
)
cpp_error
(
this
,
"Expected ) after ..."
);
tmp2
=
pos
;
tmp2
=
pos
;
if
(
!
WC_ISIDCHAR
(
data
[
pos
]))
if
(
!
WC_ISIDCHAR
(
data
[
pos
]))
...
@@ -1645,6 +1657,13 @@ static INT32 lower_cpp(struct cpp *this,
...
@@ -1645,6 +1657,13 @@ static INT32 lower_cpp(struct cpp *this,
pop_stack
();
pop_stack
();
argno
--
;
argno
--
;
}
}
if
(
data
[
pos
]
==
'.'
&&
data
[
pos
+
1
]
==
'.'
&&
data
[
pos
+
2
]
==
'.'
)
{
varargs
=
1
;
pos
+=
3
;
SKIPWHITE
();
}
}
}
if
(
!
GOBBLE
(
')'
))
if
(
!
GOBBLE
(
')'
))
...
@@ -1798,6 +1817,7 @@ static INT32 lower_cpp(struct cpp *this,
...
@@ -1798,6 +1817,7 @@ static INT32 lower_cpp(struct cpp *this,
#endif
/* SHIFT == 0 */
#endif
/* SHIFT == 0 */
copy_shared_string
(
def
->
first
,
partbase
->
u
.
string
);
copy_shared_string
(
def
->
first
,
partbase
->
u
.
string
);
def
->
args
=
argno
;
def
->
args
=
argno
;
def
->
varargs
=
varargs
;
for
(
e
=
0
;
e
<
def
->
num_parts
;
e
++
)
for
(
e
=
0
;
e
<
def
->
num_parts
;
e
++
)
{
{
...
...
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