beautify/format source code with gnu indent
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9505 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5364d135c7
commit
aa04c4c057
72 changed files with 27038 additions and 28016 deletions
|
|
@ -16,11 +16,11 @@ char cvsroot_include_c[] = "$Header$";
|
|||
|
||||
/* Delimeter used in accessing files and directories */
|
||||
|
||||
static List *directories = 0; /* List of include directories */
|
||||
static String *lastpath = 0; /* Last file that was included */
|
||||
static String *swiglib = 0; /* Location of SWIG library */
|
||||
static String *lang_config = 0; /* Language configuration file */
|
||||
static int dopush = 1; /* Whether to push directories */
|
||||
static List *directories = 0; /* List of include directories */
|
||||
static String *lastpath = 0; /* Last file that was included */
|
||||
static String *swiglib = 0; /* Location of SWIG library */
|
||||
static String *lang_config = 0; /* Language configuration file */
|
||||
static int dopush = 1; /* Whether to push directories */
|
||||
|
||||
/* This functions determine whether to push/pop dirs in the preprocessor */
|
||||
void Swig_set_push_dir(int push) {
|
||||
|
|
@ -51,13 +51,11 @@ String *Swig_get_config_file() {
|
|||
* include mechanism, but rather as a query interface for language modules.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
Swig_swiglib_set(const String_or_char *sl) {
|
||||
void Swig_swiglib_set(const String_or_char *sl) {
|
||||
swiglib = NewString(sl);
|
||||
}
|
||||
|
||||
String *
|
||||
Swig_swiglib_get() {
|
||||
String *Swig_swiglib_get() {
|
||||
return swiglib;
|
||||
}
|
||||
|
||||
|
|
@ -67,9 +65,9 @@ Swig_swiglib_get() {
|
|||
* Adds a directory to the SWIG search path.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
List *
|
||||
Swig_add_directory(const String_or_char *dirname) {
|
||||
if (!directories) directories = NewList();
|
||||
List *Swig_add_directory(const String_or_char *dirname) {
|
||||
if (!directories)
|
||||
directories = NewList();
|
||||
assert(directories);
|
||||
if (dirname) {
|
||||
String *sdir = NewString(dirname);
|
||||
|
|
@ -93,21 +91,23 @@ Swig_add_directory(const String_or_char *dirname) {
|
|||
* the preprocessor to grab files in the same directory as other included files.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
Swig_push_directory(const String_or_char *dirname) {
|
||||
void Swig_push_directory(const String_or_char *dirname) {
|
||||
String *tmp = 0;
|
||||
if (!Swig_get_push_dir()) return;
|
||||
if (!directories) directories = NewList();
|
||||
if (!Swig_get_push_dir())
|
||||
return;
|
||||
if (!directories)
|
||||
directories = NewList();
|
||||
assert(directories);
|
||||
if (!DohIsString(dirname)) {
|
||||
dirname = tmp = NewString(dirname);
|
||||
assert(dirname);
|
||||
}
|
||||
}
|
||||
if (dirname) {
|
||||
Hash *dir = NewHash();
|
||||
Setattr(dir, k_name, dirname);
|
||||
Insert(directories, 0, dir);
|
||||
if (tmp) Delete(tmp);
|
||||
if (tmp)
|
||||
Delete(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -118,11 +118,12 @@ Swig_push_directory(const String_or_char *dirname) {
|
|||
* the preprocessor.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
Swig_pop_directory() {
|
||||
if (!Swig_get_push_dir()) return;
|
||||
if (!directories) return;
|
||||
Delitem(directories,0);
|
||||
void Swig_pop_directory() {
|
||||
if (!Swig_get_push_dir())
|
||||
return;
|
||||
if (!directories)
|
||||
return;
|
||||
Delitem(directories, 0);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -131,8 +132,7 @@ Swig_pop_directory() {
|
|||
* Returns the full pathname of the last file opened.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *
|
||||
Swig_last_file() {
|
||||
String *Swig_last_file() {
|
||||
assert(lastpath);
|
||||
return lastpath;
|
||||
}
|
||||
|
|
@ -143,11 +143,10 @@ Swig_last_file() {
|
|||
* Returns a list of the current search paths.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static List *
|
||||
Swig_search_path_any(int syspath) {
|
||||
static List *Swig_search_path_any(int syspath) {
|
||||
String *filename;
|
||||
String *dirname;
|
||||
List *slist, *llist;
|
||||
List *slist, *llist;
|
||||
int i, ilen;
|
||||
|
||||
llist = 0;
|
||||
|
|
@ -156,35 +155,35 @@ Swig_search_path_any(int syspath) {
|
|||
filename = NewStringEmpty();
|
||||
assert(filename);
|
||||
#ifdef MACSWIG
|
||||
Printf(filename,"%s",SWIG_FILE_DELIMETER);
|
||||
Printf(filename, "%s", SWIG_FILE_DELIMETER);
|
||||
#else
|
||||
Printf(filename,".%s", SWIG_FILE_DELIMETER);
|
||||
Printf(filename, ".%s", SWIG_FILE_DELIMETER);
|
||||
#endif
|
||||
if (syspath) {
|
||||
llist = NewList();
|
||||
assert(llist);
|
||||
Append(llist,filename);
|
||||
Append(llist, filename);
|
||||
} else {
|
||||
Append(slist,filename);
|
||||
}
|
||||
Append(slist, filename);
|
||||
}
|
||||
ilen = Len(directories);
|
||||
for (i = 0; i < ilen; i++) {
|
||||
int issimple = 0;
|
||||
dirname = Getitem(directories,i);
|
||||
dirname = Getitem(directories, i);
|
||||
filename = NewStringEmpty();
|
||||
assert(filename);
|
||||
if (DohIsString(dirname)) {
|
||||
filename = Copy(dirname);
|
||||
issimple = 1;
|
||||
} else {
|
||||
filename = Copy(Getattr(dirname,k_name));
|
||||
filename = Copy(Getattr(dirname, k_name));
|
||||
}
|
||||
StringAppend(filename, SWIG_FILE_DELIMETER);
|
||||
|
||||
if (syspath && (issimple || !GetFlag(dirname,k_sysdir))) {
|
||||
Append(llist,filename);
|
||||
if (syspath && (issimple || !GetFlag(dirname, k_sysdir))) {
|
||||
Append(llist, filename);
|
||||
} else {
|
||||
Append(slist,filename);
|
||||
Append(slist, filename);
|
||||
/* Insert(slist,0,filename); */
|
||||
}
|
||||
Delete(filename);
|
||||
|
|
@ -192,16 +191,15 @@ Swig_search_path_any(int syspath) {
|
|||
if (syspath) {
|
||||
int ilen = Len(llist);
|
||||
for (i = 0; i < ilen; i++) {
|
||||
Append(slist,Getitem(llist,i));
|
||||
Append(slist, Getitem(llist, i));
|
||||
}
|
||||
Delete(llist);
|
||||
}
|
||||
|
||||
return slist;
|
||||
}
|
||||
}
|
||||
|
||||
List *
|
||||
Swig_search_path() {
|
||||
List *Swig_search_path() {
|
||||
return Swig_search_path_any(0);
|
||||
}
|
||||
|
||||
|
|
@ -213,36 +211,37 @@ Swig_search_path() {
|
|||
* Looks for a file and open it. Returns an open FILE * on success.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static FILE *
|
||||
Swig_open_any(const String_or_char *name, int sysfile) {
|
||||
FILE *f;
|
||||
String *filename;
|
||||
List *spath = 0;
|
||||
char *cname;
|
||||
int i, ilen;
|
||||
static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
|
||||
FILE *f;
|
||||
String *filename;
|
||||
List *spath = 0;
|
||||
char *cname;
|
||||
int i, ilen;
|
||||
|
||||
if (!directories) directories = NewList();
|
||||
if (!directories)
|
||||
directories = NewList();
|
||||
assert(directories);
|
||||
|
||||
cname = Char(name);
|
||||
filename = NewString(cname);
|
||||
assert(filename);
|
||||
f = fopen(Char(filename),"r");
|
||||
f = fopen(Char(filename), "r");
|
||||
if (!f) {
|
||||
spath = Swig_search_path_any(sysfile);
|
||||
ilen = Len(spath);
|
||||
for (i = 0; i < ilen; i++) {
|
||||
Clear(filename);
|
||||
Printf(filename,"%s%s", Getitem(spath,i), cname);
|
||||
f = fopen(Char(filename),"r");
|
||||
if (f) break;
|
||||
}
|
||||
Delete(spath);
|
||||
spath = Swig_search_path_any(sysfile);
|
||||
ilen = Len(spath);
|
||||
for (i = 0; i < ilen; i++) {
|
||||
Clear(filename);
|
||||
Printf(filename, "%s%s", Getitem(spath, i), cname);
|
||||
f = fopen(Char(filename), "r");
|
||||
if (f)
|
||||
break;
|
||||
}
|
||||
Delete(spath);
|
||||
}
|
||||
if (f) {
|
||||
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
|
||||
Replaceall(filename,"\\\\","\\"); /* remove double '\' in case any already present */
|
||||
Replaceall(filename,"\\","\\\\");
|
||||
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
|
||||
Replaceall(filename, "\\\\", "\\"); /* remove double '\' in case any already present */
|
||||
Replaceall(filename, "\\", "\\\\");
|
||||
#endif
|
||||
Delete(lastpath);
|
||||
lastpath = Copy(filename);
|
||||
|
|
@ -251,8 +250,7 @@ Swig_open_any(const String_or_char *name, int sysfile) {
|
|||
return f;
|
||||
}
|
||||
|
||||
FILE *
|
||||
Swig_open(const String_or_char *name) {
|
||||
FILE *Swig_open(const String_or_char *name) {
|
||||
return Swig_open_any(name, 0);
|
||||
}
|
||||
|
||||
|
|
@ -264,24 +262,23 @@ Swig_open(const String_or_char *name) {
|
|||
* Reads data from an open FILE * and returns it as a string.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *
|
||||
Swig_read_file(FILE *f) {
|
||||
int len;
|
||||
char buffer[4096];
|
||||
String *Swig_read_file(FILE *f) {
|
||||
int len;
|
||||
char buffer[4096];
|
||||
String *str = NewStringEmpty();
|
||||
|
||||
assert(str);
|
||||
while (fgets(buffer,4095,f)) {
|
||||
StringAppend(str,buffer);
|
||||
while (fgets(buffer, 4095, f)) {
|
||||
StringAppend(str, buffer);
|
||||
}
|
||||
len = StringLen(str);
|
||||
if (len) {
|
||||
char *cstr = Char(str);
|
||||
if (cstr[len - 1] != '\n') {
|
||||
StringAppend(str, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
@ -291,31 +288,29 @@ Swig_read_file(FILE *f) {
|
|||
* Opens a file and returns it as a string.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *
|
||||
Swig_include_any(const String_or_char *name, int sysfile) {
|
||||
FILE *f;
|
||||
String *str;
|
||||
String *file;
|
||||
static String *Swig_include_any(const String_or_char *name, int sysfile) {
|
||||
FILE *f;
|
||||
String *str;
|
||||
String *file;
|
||||
|
||||
f = Swig_open_any(name, sysfile);
|
||||
if (!f) return 0;
|
||||
if (!f)
|
||||
return 0;
|
||||
str = Swig_read_file(f);
|
||||
fclose(f);
|
||||
Seek(str,0,SEEK_SET);
|
||||
Seek(str, 0, SEEK_SET);
|
||||
file = Copy(lastpath);
|
||||
Setfile(str,file);
|
||||
Setfile(str, file);
|
||||
Delete(file);
|
||||
Setline(str,1);
|
||||
Setline(str, 1);
|
||||
return str;
|
||||
}
|
||||
|
||||
String *
|
||||
Swig_include(const String_or_char *name) {
|
||||
String *Swig_include(const String_or_char *name) {
|
||||
return Swig_include_any(name, 0);
|
||||
}
|
||||
|
||||
String *
|
||||
Swig_include_sys(const String_or_char *name) {
|
||||
String *Swig_include_sys(const String_or_char *name) {
|
||||
return Swig_include_any(name, 1);
|
||||
}
|
||||
|
||||
|
|
@ -326,15 +321,15 @@ Swig_include_sys(const String_or_char *name) {
|
|||
* Copies the contents of a file into another file
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
Swig_insert_file(const String_or_char *filename, File *outfile) {
|
||||
int Swig_insert_file(const String_or_char *filename, File *outfile) {
|
||||
char buffer[4096];
|
||||
int nbytes;
|
||||
int nbytes;
|
||||
FILE *f = Swig_open(filename);
|
||||
|
||||
if (!f) return -1;
|
||||
while ((nbytes = Read(f,buffer,4096)) > 0) {
|
||||
Write(outfile,buffer,nbytes);
|
||||
if (!f)
|
||||
return -1;
|
||||
while ((nbytes = Read(f, buffer, 4096)) > 0) {
|
||||
Write(outfile, buffer, nbytes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -350,9 +345,9 @@ Swig_insert_file(const String_or_char *filename, File *outfile) {
|
|||
|
||||
static Hash *named_files = 0;
|
||||
|
||||
void
|
||||
Swig_register_filebyname(const String_or_char *filename, File *outfile) {
|
||||
if (!named_files) named_files = NewHash();
|
||||
void Swig_register_filebyname(const String_or_char *filename, File *outfile) {
|
||||
if (!named_files)
|
||||
named_files = NewHash();
|
||||
Setattr(named_files, filename, outfile);
|
||||
}
|
||||
|
||||
|
|
@ -362,10 +357,10 @@ Swig_register_filebyname(const String_or_char *filename, File *outfile) {
|
|||
* Get a named file
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
File *
|
||||
Swig_filebyname(const String_or_char *filename) {
|
||||
if (!named_files) return 0;
|
||||
return Getattr(named_files,filename);
|
||||
File *Swig_filebyname(const String_or_char *filename) {
|
||||
if (!named_files)
|
||||
return 0;
|
||||
return Getattr(named_files, filename);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -374,18 +369,18 @@ Swig_filebyname(const String_or_char *filename) {
|
|||
* Returns the suffix of a file
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *
|
||||
Swig_file_suffix(const String_or_char *filename) {
|
||||
char *Swig_file_suffix(const String_or_char *filename) {
|
||||
char *d;
|
||||
char *c = Char(filename);
|
||||
int len = Len(filename);
|
||||
if (strlen(c)) {
|
||||
d = c + len - 1;
|
||||
while (d != c) {
|
||||
if (*d == '.') return d;
|
||||
if (*d == '.')
|
||||
return d;
|
||||
d--;
|
||||
}
|
||||
return c+len;
|
||||
return c + len;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
|
@ -396,12 +391,10 @@ Swig_file_suffix(const String_or_char *filename) {
|
|||
* Returns the filename with no suffix attached.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *
|
||||
Swig_file_basename(const String_or_char *filename)
|
||||
{
|
||||
char *Swig_file_basename(const String_or_char *filename) {
|
||||
static char tmp[1024];
|
||||
char *c;
|
||||
strcpy(tmp,Char(filename));
|
||||
strcpy(tmp, Char(filename));
|
||||
c = Swig_file_suffix(tmp);
|
||||
*c = 0;
|
||||
return tmp;
|
||||
|
|
@ -412,16 +405,16 @@ Swig_file_basename(const String_or_char *filename)
|
|||
*
|
||||
* Return the file with any leading path stripped off
|
||||
* ----------------------------------------------------------------------------- */
|
||||
char *
|
||||
Swig_file_filename(const String_or_char *filename)
|
||||
{
|
||||
char *Swig_file_filename(const String_or_char *filename) {
|
||||
static char tmp[1024];
|
||||
const char *delim = SWIG_FILE_DELIMETER;
|
||||
char *c;
|
||||
|
||||
strcpy(tmp,Char(filename));
|
||||
if ((c=strrchr(tmp,*delim))) return c+1;
|
||||
else return tmp;
|
||||
strcpy(tmp, Char(filename));
|
||||
if ((c = strrchr(tmp, *delim)))
|
||||
return c + 1;
|
||||
else
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -429,22 +422,17 @@ Swig_file_filename(const String_or_char *filename)
|
|||
*
|
||||
* Return the name of the directory associated with a file
|
||||
* ----------------------------------------------------------------------------- */
|
||||
char *
|
||||
Swig_file_dirname(const String_or_char *filename)
|
||||
{
|
||||
char *Swig_file_dirname(const String_or_char *filename) {
|
||||
static char tmp[1024];
|
||||
const char *delim = SWIG_FILE_DELIMETER;
|
||||
char *c;
|
||||
strcpy(tmp,Char(filename));
|
||||
if (!strstr(tmp,delim)) {
|
||||
strcpy(tmp, Char(filename));
|
||||
if (!strstr(tmp, delim)) {
|
||||
return "";
|
||||
}
|
||||
c = tmp + strlen(tmp) -1;
|
||||
while (*c != *delim) c--;
|
||||
c = tmp + strlen(tmp) - 1;
|
||||
while (*c != *delim)
|
||||
c--;
|
||||
*(++c) = 0;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue