Added support for Mac OS X and building with clang (bug 5601, r=dvander).
This commit is contained in:
@ -1,46 +1,108 @@
|
||||
#(C)2004-2005 AMX Mod X Development Team
|
||||
# (C)2004-2013 AMX Mod X Development Team
|
||||
# Makefile written by David "BAILOPAN" Anderson
|
||||
|
||||
#####################################
|
||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
||||
#####################################
|
||||
|
||||
OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing -fvisibility=hidden
|
||||
DEBUG_FLAGS = -g -ggdb3
|
||||
CPP = gcc-4.1
|
||||
NAME = amxxpc32
|
||||
PROJECT = amxxpc32
|
||||
OBJECTS = sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c scvars.c scmemfil.c scstate.c sclist.c sci18n.c \
|
||||
scexpand.c pawncc.c libpawnc.c prefix.c memfile.c
|
||||
|
||||
OBJECTS = sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c scvars.c scmemfil.c \
|
||||
scstate.c sclist.c sci18n.c scexpand.c pawncc.c libpawnc.c prefix.c \
|
||||
memfile.c
|
||||
##############################################
|
||||
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
||||
##############################################
|
||||
|
||||
C_OPT_FLAGS = -DNDEBUG -O2 -funroll-loops -fomit-frame-pointer -pipe
|
||||
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
|
||||
C_GCC4_FLAGS = -fvisibility=hidden
|
||||
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
|
||||
CPP = gcc
|
||||
CPP_OSX = clang
|
||||
|
||||
LINK = -lpthread
|
||||
|
||||
INCLUDE = -I.
|
||||
INCLUDE = -I.
|
||||
|
||||
BINARY = $(NAME).so
|
||||
BIN_DIR = Release
|
||||
CFLAGS += -DPAWN_CELL_SIZE=32
|
||||
################################################
|
||||
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
|
||||
################################################
|
||||
|
||||
CFLAGS += -DLINUX -DNDEBUG -DHAVE_STDINT_H -DENABLE_BINRELOC -DNO_MAIN -DPAWNC_DLL -static-libgcc
|
||||
OS := $(shell uname -s)
|
||||
|
||||
CFLAGS += $(OPT_FLAGS)
|
||||
OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o)
|
||||
ifeq "$(OS)" "Darwin"
|
||||
CPP = $(CPP_OSX)
|
||||
LIB_EXT = dylib
|
||||
CFLAGS += -DOSX
|
||||
LINK += -dynamiclib -mmacosx-version-min=10.5
|
||||
else
|
||||
LIB_EXT = so
|
||||
CFLAGS += -DLINUX
|
||||
LINK += -shared
|
||||
endif
|
||||
|
||||
LINK += -m32 -lm -ldl
|
||||
|
||||
CFLAGS += -DENABLE_BINRELOC -DNO_MAIN -DPAWNC_DLL -DHAVE_STDINT_H -fno-strict-aliasing -m32 -Wall \
|
||||
-Werror
|
||||
CPPFLAGS += -fexceptions -fno-rtti
|
||||
|
||||
BINARY = $(PROJECT).$(LIB_EXT)
|
||||
|
||||
ifeq "$(DEBUG)" "true"
|
||||
BIN_DIR = Debug
|
||||
CFLAGS += $(C_DEBUG_FLAGS)
|
||||
else
|
||||
BIN_DIR = Release
|
||||
CFLAGS += $(C_OPT_FLAGS)
|
||||
endif
|
||||
|
||||
IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")
|
||||
|
||||
ifeq "$(IS_CLANG)" "1"
|
||||
CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
|
||||
CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
|
||||
else
|
||||
CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
|
||||
CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
|
||||
endif
|
||||
|
||||
# Clang || GCC >= 4
|
||||
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
|
||||
CFLAGS += $(C_GCC4_FLAGS)
|
||||
CPPFLAGS += $(CPP_GCC4_FLAGS)
|
||||
endif
|
||||
|
||||
# Clang >= 3 || GCC >= 4.7
|
||||
ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
|
||||
CFLAGS += -Wno-delete-non-virtual-dtor
|
||||
endif
|
||||
|
||||
# OS is Linux and not using clang
|
||||
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
|
||||
LINK += -static-libgcc
|
||||
endif
|
||||
|
||||
OBJ_BIN := $(OBJECTS:%.c=$(BIN_DIR)/%.o)
|
||||
|
||||
# This will break if we include other Makefiles, but is fine for now. It allows
|
||||
# us to make a copy of this file that uses altered paths (ie. Makefile.mine)
|
||||
# or other changes without mucking up the original.
|
||||
MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
|
||||
$(BIN_DIR)/%.o: %.c
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) -m32 -o $@ -c $<
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
all:
|
||||
mkdir -p Release
|
||||
$(MAKE) pawn_make
|
||||
mkdir -p $(BIN_DIR)
|
||||
$(MAKE) -f $(MAKEFILE_NAME) $(PROJECT)
|
||||
|
||||
pawn_make: $(OBJ_LINUX)
|
||||
$(CPP) $(INCLUDE) $(CFLAGS) -m32 $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
|
||||
|
||||
debug:
|
||||
$(MAKE) all DEBUG=true
|
||||
$(PROJECT): $(OBJ_BIN)
|
||||
$(CPP) $(INCLUDE) $(OBJ_BIN) $(LINK) -o $(BIN_DIR)/$(BINARY)
|
||||
|
||||
default: all
|
||||
|
||||
clean:
|
||||
rm -rf Release/*.o
|
||||
rm -rf Release/$(BINARY)
|
||||
rm -rf $(BIN_DIR)/*.o
|
||||
rm -f $(BIN_DIR)/$(BINARY)
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#if defined FREEBSD && !defined __FreeBSD__
|
||||
#define __FreeBSD__
|
||||
#endif
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
|
||||
#include <sclinux.h>
|
||||
#endif
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
#if defined HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#if defined __LCC__ || defined __DMC__ || defined LINUX
|
||||
#if defined __LCC__ || defined __DMC__ || defined LINUX || defined __APPLE__
|
||||
#if defined HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
@ -197,7 +197,7 @@ typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx);
|
||||
#endif
|
||||
|
||||
#if !defined AMX_NO_ALIGN
|
||||
#if defined LINUX || defined __FreeBSD__
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
|
||||
#pragma pack(1) /* structures must be packed (byte-aligned) */
|
||||
#elif defined MACOS && defined __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
@ -425,7 +425,7 @@ int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value);
|
||||
amx_Register((amx), amx_NativeInfo((name),(func)), 1);
|
||||
|
||||
#if !defined AMX_NO_ALIGN
|
||||
#if defined LINUX || defined __FreeBSD__
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
|
||||
#pragma pack() /* reset default packing */
|
||||
#elif defined MACOS && defined __MWERKS__
|
||||
#pragma options align=reset
|
||||
|
@ -49,7 +49,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined AMX_NO_ALIGN
|
||||
#if defined LINUX || defined __FreeBSD__
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
|
||||
#pragma pack(1) /* structures must be packed (byte-aligned) */
|
||||
#elif defined MACOS && defined __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
@ -156,7 +156,7 @@ int AMXAPI dbg_GetArrayDim(AMX_DBG *amxdbg, const AMX_DBG_SYMBOL *sym, const AMX
|
||||
|
||||
|
||||
#if !defined AMX_NO_ALIGN
|
||||
#if defined LINUX || defined __FreeBSD__
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
|
||||
#pragma pack() /* reset default packing */
|
||||
#elif defined MACOS && defined __MWERKS__
|
||||
#pragma options align=reset
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#if defined PAWNC_DLL
|
||||
|
||||
#ifndef __linux__
|
||||
#if !defined(__linux__) && !defined(__APPLE__)
|
||||
#include "dllmain.c"
|
||||
#endif
|
||||
|
||||
@ -39,9 +39,6 @@
|
||||
# define UNUSED_PARAM(p) ((void)(p))
|
||||
# endif
|
||||
|
||||
static char *argv[MAX_ARGS];
|
||||
static int argc;
|
||||
|
||||
#if PAWN_CELL_SIZE==32
|
||||
#define EXCOMPILER Compile32
|
||||
#else
|
||||
|
@ -10,6 +10,7 @@ memfile_t *memfile_creat(const char *name, size_t init)
|
||||
mf.size = init;
|
||||
mf.base = (char *)malloc(init);
|
||||
mf.usedoffs = 0;
|
||||
mf.name = NULL;
|
||||
if (!mf.base)
|
||||
{
|
||||
return NULL;
|
||||
|
@ -9,7 +9,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct memfile_s
|
||||
{
|
||||
|
@ -41,6 +41,10 @@
|
||||
#include <endian.h>
|
||||
#endif
|
||||
|
||||
#if defined __APPLE__
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* Linux NOW has these */
|
||||
#if !defined BIG_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
|
@ -63,7 +63,7 @@
|
||||
#define PREPROC_TERM '\x7f'/* termination character for preprocessor expressions (the "DEL" code) */
|
||||
#define sDEF_PREFIX "default.inc" /* default prefix filename */
|
||||
|
||||
#if defined WIN32
|
||||
#if defined WIN32 || defined __clang__
|
||||
#define INVISIBLE
|
||||
#else
|
||||
#define INVISIBLE __attribute__((visibility("protected")))
|
||||
|
@ -35,9 +35,10 @@
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
|
||||
#include <sclinux.h>
|
||||
#include <prefix.h> /* from BinReloc, see www.autopackage.org */
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined FORTIFY
|
||||
@ -421,7 +422,7 @@ int pc_compile(int argc, char *argv[])
|
||||
void *inpfmark;
|
||||
int lcl_packstr,lcl_needsemicolon,lcl_tabsize;
|
||||
#if !defined SC_LIGHT
|
||||
int hdrsize;
|
||||
int hdrsize=0;
|
||||
#endif
|
||||
|
||||
/* set global variables to their initial value */
|
||||
@ -1248,9 +1249,9 @@ static void setconfig(char *root)
|
||||
/* add the default "include" directory */
|
||||
#if defined __WIN32__ || defined _WIN32
|
||||
GetModuleFileName(NULL,path,_MAX_PATH);
|
||||
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
|
||||
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
|
||||
/* see www.autopackage.org for the BinReloc module */
|
||||
ptr = SELFPATH;
|
||||
ptr = (char *)SELFPATH;
|
||||
if (!ptr)
|
||||
ptr = root;
|
||||
strncpy(path,ptr,sizeof path);
|
||||
@ -1922,7 +1923,7 @@ static int declloc(int fstatic)
|
||||
int dim[sDIMEN_MAX];
|
||||
int numdim;
|
||||
int fconst;
|
||||
int staging_start;
|
||||
int staging_start=0;
|
||||
|
||||
fconst=matchtoken(tCONST);
|
||||
do {
|
||||
@ -1948,7 +1949,7 @@ static int declloc(int fstatic)
|
||||
* level might indicate a bug.
|
||||
* NOTE - don't bother with the error if there's no valid function!
|
||||
*/
|
||||
if ((sym=findloc(name))!=NULL && sym->compound!=nestlevel || findglb(name)!=NULL)
|
||||
if (((sym=findloc(name))!=NULL && sym->compound!=nestlevel) || findglb(name)!=NULL)
|
||||
if (curfunc!=NULL && (curfunc->usage & uNATIVE))
|
||||
error(219,name); /* variable shadows another symbol */
|
||||
while (matchtoken('[')){
|
||||
@ -2863,7 +2864,7 @@ static int operatoradjust(int opertok,symbol *sym,char *opername,int resulttag)
|
||||
error(62); /* number or placement of the operands does not fit the operator */
|
||||
} /* switch */
|
||||
|
||||
if (tags[0]==0 && (opertok!='=' && tags[1]==0 || opertok=='=' && resulttag==0))
|
||||
if (tags[0]==0 && ((opertok!='=' && tags[1]==0) || (opertok=='=' && resulttag==0)))
|
||||
error(64); /* cannot change predefined operators */
|
||||
|
||||
/* change the operator name */
|
||||
@ -3045,7 +3046,7 @@ static void funcstub(int native)
|
||||
|
||||
tok=lex(&val,&str);
|
||||
if (native) {
|
||||
if (tok==tPUBLIC || tok==tSTOCK || tok==tSTATIC || tok==tSYMBOL && *str==PUBLIC_CHAR)
|
||||
if (tok==tPUBLIC || tok==tSTOCK || tok==tSTATIC || (tok==tSYMBOL && *str==PUBLIC_CHAR))
|
||||
error(42); /* invalid combination of class specifiers */
|
||||
} else {
|
||||
if (tok==tPUBLIC || tok==tSTOCK || tok==tSTATIC)
|
||||
@ -3166,7 +3167,7 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
|
||||
tag= (firsttag>=0) ? firsttag : pc_addtag(NULL);
|
||||
tok=lex(&val,&str);
|
||||
assert(!fpublic);
|
||||
if (tok==tNATIVE || tok==tPUBLIC && stock)
|
||||
if (tok==tNATIVE || (tok==tPUBLIC && stock))
|
||||
error(42); /* invalid combination of class specifiers */
|
||||
if (tok==tOPERATOR) {
|
||||
opertok=operatorname(symbolname);
|
||||
@ -3512,7 +3513,7 @@ static int declargs(symbol *sym)
|
||||
error(10); /* illegal function or declaration */
|
||||
} /* switch */
|
||||
} while (tok=='&' || tok==tLABEL || tok==tCONST
|
||||
|| tok!=tELLIPS && matchtoken(',')); /* more? */
|
||||
|| (tok!=tELLIPS && matchtoken(','))); /* more? */
|
||||
/* if the next token is not ",", it should be ")" */
|
||||
needtoken(')');
|
||||
} /* if */
|
||||
@ -3873,7 +3874,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile)
|
||||
continue;
|
||||
if ((sym->usage & uREAD)==0)
|
||||
continue;
|
||||
fprintf(log,"\t\t<member name=\"T:%s\" value=\"%ld\">\n",funcdisplayname(symname,sym->name),sym->addr);
|
||||
fprintf(log,"\t\t<member name=\"T:%s\" value=\"%ld\">\n",funcdisplayname(symname,sym->name),(long)sym->addr);
|
||||
if (sym->tag!=0) {
|
||||
tagsym=find_tag_byval(sym->tag);
|
||||
assert(tagsym!=NULL);
|
||||
@ -3883,7 +3884,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile)
|
||||
if ((enumroot=sym->dim.enumlist)!=NULL) {
|
||||
enumroot=enumroot->next; /* skip root */
|
||||
while (enumroot!=NULL) {
|
||||
fprintf(log,"\t\t\t<member name=\"C:%s\" value=\"%ld\">\n",funcdisplayname(symname,enumroot->name),enumroot->value);
|
||||
fprintf(log,"\t\t\t<member name=\"C:%s\" value=\"%ld\">\n",funcdisplayname(symname,enumroot->name),(long)enumroot->value);
|
||||
/* find the constant with this name and get the tag */
|
||||
ref=findglb(enumroot->name);
|
||||
if (ref!=NULL) {
|
||||
@ -3919,7 +3920,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile)
|
||||
continue;
|
||||
if ((sym->usage & uREAD)==0 || (sym->usage & (uENUMFIELD | uENUMROOT))!=0)
|
||||
continue;
|
||||
fprintf(log,"\t\t<member name=\"C:%s\" value=\"%ld\">\n",funcdisplayname(symname,sym->name),sym->addr);
|
||||
fprintf(log,"\t\t<member name=\"C:%s\" value=\"%ld\">\n",funcdisplayname(symname,sym->name),(long)sym->addr);
|
||||
if (sym->tag!=0) {
|
||||
tagsym=find_tag_byval(sym->tag);
|
||||
assert(tagsym!=NULL);
|
||||
@ -4039,7 +4040,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile)
|
||||
for (arg=0; sym->dim.arglist[arg].ident!=0; arg++) {
|
||||
int dim,paraminfo;
|
||||
char *outer_start,*inner_start;
|
||||
int outer_length,inner_length;
|
||||
int outer_length=0,inner_length=0;
|
||||
if (sym->dim.arglist[arg].ident==iVARARGS)
|
||||
fprintf(log,"\t\t\t<param name=\"...\">\n");
|
||||
else
|
||||
@ -5248,7 +5249,7 @@ static void doreturn(void)
|
||||
if ((rettype & uRETVALUE)!=0) {
|
||||
int retarray=(ident==iARRAY || ident==iREFARRAY);
|
||||
/* there was an earlier "return" statement in this function */
|
||||
if (sub==NULL && retarray || sub!=NULL && !retarray)
|
||||
if ((sub==NULL && retarray) || (sub!=NULL && !retarray))
|
||||
error(79); /* mixing "return array;" and "return value;" */
|
||||
} /* if */
|
||||
rettype|=uRETVALUE; /* function returns a value */
|
||||
@ -5257,7 +5258,7 @@ static void doreturn(void)
|
||||
if (!matchtag(curfunc->tag,tag,TRUE))
|
||||
error(213); /* tagname mismatch */
|
||||
if (ident==iARRAY || ident==iREFARRAY) {
|
||||
int dim[sDIMEN_MAX],numdim;
|
||||
int dim[sDIMEN_MAX],numdim=0;
|
||||
cell arraysize;
|
||||
assert(sym!=NULL);
|
||||
if (sub!=NULL) {
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include "sc.h"
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
|
||||
#include <sclinux.h>
|
||||
#endif
|
||||
|
||||
@ -198,7 +198,7 @@ SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths)
|
||||
char path[_MAX_PATH];
|
||||
strncpy(path,ptr,sizeof path);
|
||||
path[sizeof path - 1]='\0'; /* force '\0' termination */
|
||||
strncat(path,name,sizeof(path)-strlen(path));
|
||||
strncat(path,name,sizeof(path) - strlen(path) - 1);
|
||||
path[sizeof path - 1]='\0';
|
||||
result=plungequalifiedfile(path);
|
||||
} /* while */
|
||||
@ -408,7 +408,7 @@ static void stripcom(unsigned char *line)
|
||||
#if !defined SC_LIGHT
|
||||
/* collect the comment characters in a string */
|
||||
if (icomment==2) {
|
||||
if (skipstar && (*line!='\0' && *line<=' ' || *line=='*')) {
|
||||
if (skipstar && ((*line!='\0' && *line<=' ') || *line=='*')) {
|
||||
/* ignore leading whitespace and '*' characters */
|
||||
} else if (commentidx<COMMENT_LIMIT+COMMENT_MARGIN-1) {
|
||||
comment[commentidx++]=(char)((*line!='\n') ? *line : ' ');
|
||||
@ -585,22 +585,9 @@ static int htoi(cell *val,const unsigned char *curptr)
|
||||
}
|
||||
|
||||
#if defined __GNUC__
|
||||
static double pow10(int value)
|
||||
static double pow10(double d)
|
||||
{
|
||||
double res=1.0;
|
||||
while (value>=4) {
|
||||
res*=10000.0;
|
||||
value-=5;
|
||||
} /* while */
|
||||
while (value>=2) {
|
||||
res*=100.0;
|
||||
value-=2;
|
||||
} /* while */
|
||||
while (value>=1) {
|
||||
res*=10.0;
|
||||
value-=1;
|
||||
} /* while */
|
||||
return res;
|
||||
return pow(10, d);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1210,7 +1197,7 @@ static int command(void)
|
||||
sym=findloc(str);
|
||||
if (sym==NULL)
|
||||
sym=findglb(str);
|
||||
if (sym==NULL || sym->ident!=iFUNCTN && sym->ident!=iREFFUNC && (sym->usage & uDEFINE)==0) {
|
||||
if (sym==NULL || (sym->ident!=iFUNCTN && sym->ident!=iREFFUNC && (sym->usage & uDEFINE)==0)) {
|
||||
error(17,str); /* undefined symbol */
|
||||
} else {
|
||||
outval(sym->addr,FALSE);
|
||||
@ -1644,7 +1631,7 @@ static void substallpatterns(unsigned char *line,int buffersize)
|
||||
if (strncmp((char*)start,"defined",7)==0 && !isalpha((char)*(start+7))) {
|
||||
start+=7; /* skip "defined" */
|
||||
/* skip white space & parantheses */
|
||||
while (*start<=' ' && *start!='\0' || *start=='(')
|
||||
while ((*start<=' ' && *start!='\0') || *start=='(')
|
||||
start++;
|
||||
/* skip the symbol behind it */
|
||||
while (isalpha(*start) || isdigit(*start) || *start=='_')
|
||||
@ -1946,7 +1933,7 @@ SC_FUNC int lex(cell *lexvalue,char **lexsym)
|
||||
error(220);
|
||||
} /* if */
|
||||
} /* if */
|
||||
} else if (*lptr=='\"' || *lptr==sc_ctrlchar && *(lptr+1)=='\"')
|
||||
} else if (*lptr=='\"' || (*lptr==sc_ctrlchar && *(lptr+1)=='\"'))
|
||||
{ /* unpacked string literal */
|
||||
_lextok=tSTRING;
|
||||
stringflags= (*lptr==sc_ctrlchar) ? RAWMODE : 0;
|
||||
@ -1959,9 +1946,9 @@ SC_FUNC int lex(cell *lexvalue,char **lexsym)
|
||||
lptr+=1; /* skip final quote */
|
||||
else
|
||||
error(37); /* invalid (non-terminated) string */
|
||||
} else if (*lptr=='!' && *(lptr+1)=='\"'
|
||||
|| *lptr=='!' && *(lptr+1)==sc_ctrlchar && *(lptr+2)=='\"'
|
||||
|| *lptr==sc_ctrlchar && *(lptr+1)=='!' && *(lptr+2)=='\"')
|
||||
} else if ((*lptr=='!' && *(lptr+1)=='\"')
|
||||
|| (*lptr=='!' && *(lptr+1)==sc_ctrlchar && *(lptr+2)=='\"')
|
||||
|| (*lptr==sc_ctrlchar && *(lptr+1)=='!' && *(lptr+2)=='\"'))
|
||||
{ /* packed string literal */
|
||||
_lextok=tSTRING;
|
||||
stringflags= (*lptr==sc_ctrlchar || *(lptr+1)==sc_ctrlchar) ? RAWMODE : 0;
|
||||
@ -2053,7 +2040,7 @@ SC_FUNC int matchtoken(int token)
|
||||
int tok;
|
||||
|
||||
tok=lex(&val,&str);
|
||||
if (tok==token || token==tTERM && (tok==';' || tok==tENDEXPR)) {
|
||||
if (tok==token || (token==tTERM && (tok==';' || tok==tENDEXPR))) {
|
||||
return 1;
|
||||
} else if (!sc_needsemicolon && token==tTERM && (_lexnewline || !freading)) {
|
||||
/* Push "tok" back, because it is the token following the implicit statement
|
||||
@ -2418,7 +2405,7 @@ SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_
|
||||
{
|
||||
symbol *sym,*parent_sym;
|
||||
constvalue *stateptr;
|
||||
int mustdelete;
|
||||
int mustdelete=0;
|
||||
|
||||
/* erase only the symbols with a deeper nesting level than the
|
||||
* specified nesting level */
|
||||
|
@ -929,7 +929,7 @@ static int hier14(value *lval1)
|
||||
} /* if */
|
||||
if (lval3.sym->dim.array.level!=level)
|
||||
return error(48); /* array dimensions must match */
|
||||
else if (ltlength<val || exactmatch && ltlength>val || val==0)
|
||||
else if (ltlength<val || (exactmatch && ltlength>val) || val==0)
|
||||
return error(47); /* array sizes must match */
|
||||
else if (lval3.ident!=iARRAYCELL && !matchtag(lval3.sym->x.idxtag,idxtag,TRUE))
|
||||
error(229,(lval2.sym!=NULL) ? lval2.sym->name : lval3.sym->name); /* index tag mismatch */
|
||||
@ -1124,7 +1124,7 @@ static int hier2(value *lval)
|
||||
int tag,paranthese;
|
||||
cell val;
|
||||
char *st;
|
||||
symbol *sym;
|
||||
symbol *sym=NULL;
|
||||
int saveresult;
|
||||
|
||||
tok=lex(&val,&st);
|
||||
@ -1247,7 +1247,7 @@ static int hier2(value *lval)
|
||||
lval->constval=1; /* preset */
|
||||
if (sym->ident==iARRAY || sym->ident==iREFARRAY) {
|
||||
int level;
|
||||
symbol *idxsym;
|
||||
symbol *idxsym=NULL;
|
||||
for (level=0; matchtoken('['); level++) {
|
||||
idxsym=NULL;
|
||||
if (level==sym->dim.array.level && matchtoken(tSYMBOL)) {
|
||||
@ -1293,7 +1293,7 @@ static int hier2(value *lval)
|
||||
} /* if */
|
||||
if (sym->ident==iARRAY || sym->ident==iREFARRAY) {
|
||||
int level;
|
||||
symbol *idxsym;
|
||||
symbol *idxsym=NULL;
|
||||
for (level=0; matchtoken('['); level++) {
|
||||
idxsym=NULL;
|
||||
if (level==sym->dim.array.level && matchtoken(tSYMBOL)) {
|
||||
@ -1462,7 +1462,7 @@ restart:
|
||||
} /* if */
|
||||
if (close==']') {
|
||||
/* normal array index */
|
||||
if (lval2.constval<0 || sym->dim.array.length!=0 && sym->dim.array.length<=lval2.constval)
|
||||
if (lval2.constval<0 || (sym->dim.array.length!=0 && sym->dim.array.length<=lval2.constval))
|
||||
error(32,sym->name); /* array index out of bounds */
|
||||
if (lval2.constval!=0) {
|
||||
/* don't add offsets for zero subscripts */
|
||||
@ -1479,8 +1479,8 @@ restart:
|
||||
} /* if */
|
||||
} else {
|
||||
/* character index */
|
||||
if (lval2.constval<0 || sym->dim.array.length!=0
|
||||
&& sym->dim.array.length*((8*sizeof(cell))/sCHARBITS)<=(ucell)lval2.constval)
|
||||
if (lval2.constval<0 || (sym->dim.array.length!=0
|
||||
&& sym->dim.array.length*((8*sizeof(cell))/sCHARBITS)<=(ucell)lval2.constval))
|
||||
error(32,sym->name); /* array index out of bounds */
|
||||
if (lval2.constval!=0) {
|
||||
/* don't add offsets for zero subscripts */
|
||||
@ -2035,8 +2035,8 @@ static int nesting=0;
|
||||
* function argument; a literal string may be smaller than
|
||||
* the function argument.
|
||||
*/
|
||||
if (lval.constval>0 && arg[argidx].dim[0]!=lval.constval
|
||||
|| lval.constval<0 && arg[argidx].dim[0] < -lval.constval)
|
||||
if ((lval.constval>0 && arg[argidx].dim[0]!=lval.constval)
|
||||
|| (lval.constval<0 && arg[argidx].dim[0] < -lval.constval))
|
||||
error(47); /* array sizes must match */
|
||||
} /* if */
|
||||
} /* if */
|
||||
|
@ -235,7 +235,7 @@ SC_FUNC void begdseg(void)
|
||||
|
||||
SC_FUNC void setline(int chkbounds)
|
||||
{
|
||||
if ((sc_debug & sSYMBOLIC)!=0 || chkbounds && (sc_debug & sCHKBOUNDS)!=0) {
|
||||
if ((sc_debug & sSYMBOLIC)!=0 || (chkbounds && (sc_debug & sCHKBOUNDS)!=0)) {
|
||||
/* generate a "break" (start statement) opcode rather than a "line" opcode
|
||||
* because earlier versions of Small/Pawn have an incompatible version of the
|
||||
* line opcode
|
||||
@ -719,7 +719,7 @@ SC_FUNC void ffcall(symbol *sym,const char *label,int numargs)
|
||||
stgwrite(sym->name);
|
||||
} /* if */
|
||||
if (sc_asmfile
|
||||
&& (label!=NULL || !isalpha(sym->name[0]) && sym->name[0]!='_' && sym->name[0]!=sc_ctrlchar))
|
||||
&& (label!=NULL || (!isalpha(sym->name[0]) && sym->name[0]!='_' && sym->name[0]!=sc_ctrlchar)))
|
||||
{
|
||||
stgwrite("\t; ");
|
||||
stgwrite(symname);
|
||||
|
@ -25,7 +25,7 @@
|
||||
#if defined __WIN32__ || defined _WIN32 || defined __MSDOS__
|
||||
#include <io.h>
|
||||
#endif
|
||||
#if defined LINUX || defined __GNUC__
|
||||
#if defined LINUX || defined __APPLE__ || defined __GNUC__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
@ -132,7 +132,7 @@ static short lastfile;
|
||||
} /* if */
|
||||
va_end(argptr);
|
||||
|
||||
if (number>=100 && number<200 || errnum>25){
|
||||
if ((number>=100 && number<200) || errnum>25){
|
||||
if (strlen(errfname)==0) {
|
||||
va_start(argptr,number);
|
||||
pc_error(0,"\nCompilation aborted.",NULL,0,0,argptr);
|
||||
|
@ -30,7 +30,7 @@
|
||||
#endif
|
||||
#include "sc.h"
|
||||
#include "amxdbg.h"
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
|
||||
#include <sclinux.h>
|
||||
#endif
|
||||
|
||||
@ -895,7 +895,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
|
||||
instr=skipwhitespace(line);
|
||||
/* ignore empty lines and labels (labels have a special syntax, so these
|
||||
* must be parsed separately) */
|
||||
if (*instr=='\0' || tolower(*instr)=='l' && *(instr+1)=='.')
|
||||
if (*instr=='\0' || (tolower(*instr)=='l' && *(instr+1)=='.'))
|
||||
continue;
|
||||
/* get to the end of the instruction (make use of the '\n' that fgets()
|
||||
* added at the end of the line; this way we will *always* drop on a
|
||||
|
@ -457,18 +457,18 @@ static int matchsequence(char *start,char *end,char *pattern,
|
||||
case ' ':
|
||||
if (*start!='\t' && *start!=' ')
|
||||
return FALSE;
|
||||
while (start<end && *start=='\t' || *start==' ')
|
||||
while ((start<end && *start=='\t') || *start==' ')
|
||||
start++;
|
||||
break;
|
||||
case '!':
|
||||
while (start<end && *start=='\t' || *start==' ')
|
||||
while ((start<end && *start=='\t') || *start==' ')
|
||||
start++; /* skip trailing white space */
|
||||
if (*start!='\n')
|
||||
return FALSE;
|
||||
assert(*(start+1)=='\0');
|
||||
start+=2; /* skip '\n' and '\0' */
|
||||
if (*(pattern+1)!='\0')
|
||||
while (start<end && *start=='\t' || *start==' ')
|
||||
while ((start<end && *start=='\t') || *start==' ')
|
||||
start++; /* skip leading white space of next instruction */
|
||||
break;
|
||||
default:
|
||||
|
@ -47,7 +47,7 @@
|
||||
#define _MAX_PATH 250
|
||||
#endif
|
||||
#if !defined DIRSEP_CHAR
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE___
|
||||
#define DIRSEP_CHAR '/'
|
||||
#elif defined macintosh
|
||||
#define DIRSEP_CHAR ':'
|
||||
@ -339,7 +339,7 @@ SC_FUNC cell get_utf8_char(const unsigned char *string,const unsigned char **end
|
||||
/* the code positions 0xd800--0xdfff and 0xfffe & 0xffff do not
|
||||
* exist in UCS-4 (and hence, they do not exist in Unicode)
|
||||
*/
|
||||
if (result>=0xd800 && result<=0xdfff || result==0xfffe || result==0xffff)
|
||||
if ((result>=0xd800 && result<=0xdfff) || result==0xfffe || result==0xffff)
|
||||
return -1;
|
||||
} /* if */
|
||||
break;
|
||||
|
@ -32,6 +32,10 @@
|
||||
*/
|
||||
#if !defined __BYTE_ORDER
|
||||
# include <stdlib.h>
|
||||
# if defined __APPLE__
|
||||
# include <sys/types.h>
|
||||
# define __BYTE_ORDER BYTE_ORDER
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined __OpenBSD__ || defined __FreeBSD__
|
||||
|
@ -238,7 +238,7 @@ SC_FUNC stringlist *insert_path(char *path)
|
||||
{
|
||||
char *extra_path = malloc(strlen(path) + 16);
|
||||
strcpy(extra_path, path);
|
||||
#if defined __linux__
|
||||
#if defined __linux__ || defined __APPLE__
|
||||
strcat(extra_path, "/amxmod_compat/");
|
||||
#elif defined WIN32 || defined _WIN32
|
||||
strcat(extra_path, "\\amxmod_compat\\");
|
||||
@ -444,10 +444,10 @@ SC_FUNC stringlist *insert_dbgsymbol(symbol *sym)
|
||||
/* address tag:name codestart codeend ident vclass [tag:dim ...] */
|
||||
#if PAWN_CELL_SIZE==32
|
||||
if (sym->ident==iFUNCTN)
|
||||
sprintf(string,"S:%08lx %x:%s %08lx %08lx %x %x",sym->addr,sym->tag,
|
||||
sprintf(string,"S:%08x %x:%s %08x %08x %x %x",sym->addr,sym->tag,
|
||||
symname,sym->addr,sym->codeaddr,sym->ident,sym->vclass);
|
||||
else
|
||||
sprintf(string,"S:%08lx %x:%s %08lx %08lx %x %x",sym->addr,sym->tag,
|
||||
sprintf(string,"S:%08x %x:%s %08x %08x %x %x",sym->addr,sym->tag,
|
||||
symname,sym->codeaddr,code_idx,sym->ident,sym->vclass);
|
||||
#elif PAWN_CELL_SIZE==64
|
||||
if (sym->ident==iFUNCTN)
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "sc.h"
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
|
||||
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
|
||||
#include <sclinux.h>
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user