some clean-up's to come through MSC
This commit is contained in:
parent
90f5a541ff
commit
41325622fd
|
|
@ -21,7 +21,9 @@ void
|
|||
com_chdir(wordlist *wl)
|
||||
{
|
||||
char *s;
|
||||
#ifdef HAVE_PWD_H
|
||||
struct passwd *pw;
|
||||
#endif
|
||||
char localbuf[257];
|
||||
int copied = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,9 @@ $Id$
|
|||
* the listing routines.
|
||||
*/
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
#include "ngspice.h"
|
||||
#include "cpdefs.h"
|
||||
#include "inpdefs.h"
|
||||
|
|
@ -24,6 +26,7 @@ $Id$
|
|||
#include "fteinp.h"
|
||||
#include "inp.h"
|
||||
|
||||
#include "inpcom.h"
|
||||
#include "circuits.h"
|
||||
#include "completion.h"
|
||||
#include "variable.h"
|
||||
|
|
@ -640,6 +643,7 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse,
|
|||
wordlist *wl;
|
||||
bool noparse, ii;
|
||||
bool brief;
|
||||
int print_listing;
|
||||
|
||||
/* First throw away any old error messages there might be and fix
|
||||
* the case of the lines. */
|
||||
|
|
@ -761,7 +765,7 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse,
|
|||
/* output deck */
|
||||
out_printf( "\nProcessed Netlist\n" );
|
||||
out_printf( "=================\n" );
|
||||
int print_listing = 1;
|
||||
print_listing = 1;
|
||||
for (dd = deck; dd; dd = dd->li_next) {
|
||||
if ( ciprefix(".prot", dd->li_line) ) print_listing = 0;
|
||||
if ( print_listing == 1 ) out_printf( "%s\n", dd->li_line );
|
||||
|
|
|
|||
|
|
@ -30,8 +30,10 @@ Author: 1985 Wayne A. Christopher
|
|||
* Fixed crash where a NULL pointer gets freed in inp_readall()
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
#include <config.h>
|
||||
#include "ngspice.h"
|
||||
#include "cpdefs.h"
|
||||
#include "ftedefs.h"
|
||||
|
|
@ -973,7 +975,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
|
|||
struct line *end = NULL, *cc = NULL, *prev = NULL, *working, *newcard, *start_lib, *global_card, *tmp_ptr = NULL, *tmp_ptr2 = NULL;
|
||||
char *buffer = NULL, *s, *t, *y, *z, c;
|
||||
/* segfault fix */
|
||||
char *copys=NULL, big_buff[5000], big_buff2[5000];
|
||||
char *copys=NULL, big_buff2[5000];
|
||||
char *global_copy = NULL, keep_char;
|
||||
int line_number = 1; /* sjb - renamed to avoid confusion with struct line */
|
||||
int line_count = 0;
|
||||
|
|
@ -983,6 +985,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
|
|||
bool dir_name_flag = FALSE;
|
||||
|
||||
struct variable *v;
|
||||
char *s_ptr, *s_lower;
|
||||
|
||||
/* Must set this to NULL or non-tilde includes segfault. -- Tim Molteno */
|
||||
/* copys = NULL; */ /* This caused a parse error with gcc 2.96. Why??? */
|
||||
|
|
@ -1030,7 +1033,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
|
|||
break;
|
||||
}
|
||||
else if(ipc_status == IPC_STATUS_OK) {
|
||||
buffer = (void *) MALLOC(strlen(ipc_buffer) + 3);
|
||||
// buffer = (void *) MALLOC(strlen(ipc_buffer) + 3);
|
||||
buffer = (void *) tmalloc(strlen(ipc_buffer) + 3);
|
||||
strcpy(buffer, ipc_buffer);
|
||||
strcat(buffer, "\n");
|
||||
}
|
||||
|
|
@ -1092,7 +1096,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
|
|||
}
|
||||
|
||||
/* lower case the file name for later string compares */
|
||||
char *s_ptr, *s_lower = strdup(s);
|
||||
s_ptr = strdup(s);
|
||||
s_lower = strdup(s);
|
||||
for(s_ptr = s_lower; *s_ptr && (*s_ptr != '\n'); s_ptr++) *s_ptr = tolower(*s_ptr);
|
||||
|
||||
found_library = FALSE;
|
||||
|
|
@ -2074,6 +2079,8 @@ inp_fix_inst_calls_for_numparam(struct line *deck)
|
|||
int num_inst_params = 0;
|
||||
int i,j,k;
|
||||
bool flag = FALSE;
|
||||
bool found_subckt = FALSE;
|
||||
bool found_param_match = FALSE;
|
||||
|
||||
// first iterate through instances and find occurences where 'm' multiplier needs to be
|
||||
// added to the subcircuit -- subsequent instances will then need this parameter as well
|
||||
|
|
@ -2126,7 +2133,7 @@ inp_fix_inst_calls_for_numparam(struct line *deck)
|
|||
sprintf( name_w_space, "%s ", subckt_name );
|
||||
|
||||
/* find .subckt line */
|
||||
bool found_subckt = FALSE;
|
||||
found_subckt = FALSE;
|
||||
|
||||
d = deck;
|
||||
while ( d != NULL ) {
|
||||
|
|
@ -2140,7 +2147,7 @@ inp_fix_inst_calls_for_numparam(struct line *deck)
|
|||
num_inst_params = inp_get_params( inst_line, inst_param_names, inst_param_values );
|
||||
|
||||
// make sure that if have inst params that one matches subckt
|
||||
bool found_param_match = FALSE;
|
||||
found_param_match = FALSE;
|
||||
if ( num_inst_params == 0 ) found_param_match = TRUE;
|
||||
else {
|
||||
for ( j = 0; j < num_inst_params; j++ ) {
|
||||
|
|
@ -2363,7 +2370,7 @@ inp_expand_macro_in_str( char *str )
|
|||
char *open_paren_ptr, *close_paren_ptr, *fcn_name, *comma_ptr, *params[1000];
|
||||
char *curr_ptr, *new_str, *macro_str, *curr_str = NULL;
|
||||
int num_parens, num_params;
|
||||
char *orig_ptr = str, *search_ptr = str, *orig_str = strdup(str);;
|
||||
char *orig_ptr = str, *search_ptr = str, *orig_str = strdup(str);
|
||||
char keep;
|
||||
|
||||
while ( ( open_paren_ptr = strstr( search_ptr, "(" ) ) ) {
|
||||
|
|
@ -2666,6 +2673,7 @@ inp_sort_params( struct line *start_card, struct line *end_card, struct line *ca
|
|||
char *param_names[12000], *param_strs[12000], *curr_line;
|
||||
char *depends_on[12000][100], *str_ptr, *beg, *end, *new_str;
|
||||
int level[12000], param_skip[12000], skipped = 0;
|
||||
bool found_in_list = FALSE;
|
||||
|
||||
if ( start_card == NULL ) return;
|
||||
|
||||
|
|
@ -2724,7 +2732,7 @@ inp_sort_params( struct line *start_card, struct line *end_card, struct line *ca
|
|||
!isalnum( *(param_ptr+strlen(param_name)) ) && *(param_ptr+strlen(param_name)) != '_' )
|
||||
{
|
||||
index = 0;
|
||||
bool found_in_list = FALSE;
|
||||
found_in_list = FALSE;
|
||||
while ( depends_on[j][index] != NULL ) {
|
||||
if ( strcmp( param_name, depends_on[j][index] ) == 0 ) { found_in_list = TRUE; break; }
|
||||
index++;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ FILE * inp_pathopen(char *name, char *mode);
|
|||
void inp_readall(FILE *fp, struct line **data, int, char *dirname);
|
||||
void inp_casefix(register char *string);
|
||||
|
||||
char *basename(char *name);
|
||||
char *dirname(char *name);
|
||||
|
||||
/* globals -- wanted to avoid complicating inp_readall interface */
|
||||
static char *library_file[1000];
|
||||
static char *library_name[1000][1000];
|
||||
|
|
|
|||
|
|
@ -17,12 +17,13 @@ static bool measures_passed;
|
|||
// some limitations.
|
||||
static bool AlmostEqualUlps(float A, float B, int maxUlps)
|
||||
{
|
||||
int intDiff;
|
||||
assert(sizeof(float) == sizeof(int));
|
||||
|
||||
if (A == B)
|
||||
return TRUE;
|
||||
|
||||
int intDiff = abs(*(int*)&A - *(int*)&B);
|
||||
intDiff = abs(*(int*)&A - *(int*)&B);
|
||||
|
||||
if (intDiff <= maxUlps)
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ Modified: 1999 Paolo Nenzi
|
|||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#if !defined(__MINGW32__) && !defined(_MSC_VER)
|
||||
/* MW. We also need ioctl.h here I think */
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ $Id$
|
|||
|
||||
#include "spec.h"
|
||||
#include "variable.h"
|
||||
#include "missing_math.h"
|
||||
|
||||
void
|
||||
com_spec(wordlist *wl)
|
||||
|
|
|
|||
|
|
@ -135,17 +135,17 @@ extern int scannum(char *str);
|
|||
extern int ciprefix(register char *p, register char *s);
|
||||
extern int cieq(register char *p, register char *s);
|
||||
extern void strtolower(char *str);
|
||||
extern char *tildexpand(char *string);
|
||||
extern char *tildexpand(char *str);
|
||||
|
||||
extern char *canonicalize_pathname(char *path);
|
||||
extern char *absolute_pathname(char *string, char *dot_path);
|
||||
extern char *absolute_pathname(char *str, char *dot_path);
|
||||
|
||||
extern char *smktemp(char *id);
|
||||
|
||||
extern char *copy(char *str);
|
||||
extern int prefix(char *p, char *str);
|
||||
extern int substring(char *sub, char *str);
|
||||
extern void cp_printword(char *string, FILE *fp);
|
||||
extern void cp_printword(char *str, FILE *fp);
|
||||
|
||||
extern char *datestring(void);
|
||||
extern double seconds(void);
|
||||
|
|
|
|||
|
|
@ -842,7 +842,7 @@ main(int argc, char **argv)
|
|||
if (optarg) {
|
||||
cp_vset("rawfile", VT_STRING, optarg);
|
||||
}
|
||||
//rflag = TRUE;
|
||||
/* rflag = TRUE; */
|
||||
break;
|
||||
|
||||
case 's': /* Server mode */
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ NIiter(CKTcircuit *ckt, int maxIter)
|
|||
double startTime;
|
||||
static char *msg = "Too many iterations without convergence";
|
||||
|
||||
if ( maxIter < 100 ) maxIter = 100; /* some convergence issues that get resolved by increasing max iter */
|
||||
|
||||
CKTnode *node; /* current matrix entry */
|
||||
double diff, maxdiff, damp_factor, *OldCKTstate0=NULL;
|
||||
|
||||
if ( maxIter < 100 ) maxIter = 100; /* some convergence issues that get resolved by increasing max iter */
|
||||
|
||||
iterno=0;
|
||||
ipass=0;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,11 @@ Modified: 2002 R. Oktas, <roktas@omu.edu.tr>
|
|||
char *
|
||||
tildexpand(char *string)
|
||||
{
|
||||
#ifdef HAVE_PWD_H
|
||||
char buf[BSIZE_SP];
|
||||
char *result = NULL, *k, c;
|
||||
char *k, c;
|
||||
#endif
|
||||
char *result = NULL;
|
||||
|
||||
if (!string)
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -149,3 +149,84 @@ char * absolute_pathname(char *string, char *dot_path)
|
|||
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
const char *
|
||||
basename(const char *name)
|
||||
{
|
||||
const char *base;
|
||||
char *p;
|
||||
static char *tmp = NULL;
|
||||
int len;
|
||||
|
||||
if (tmp) {
|
||||
free(tmp);
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
if (!name || !strcmp(name, ""))
|
||||
return "";
|
||||
|
||||
if (!strcmp(name, "/"))
|
||||
return "/";
|
||||
|
||||
len = strlen(name);
|
||||
if (name[len - 1] == '/') {
|
||||
// ditch the trailing '/'
|
||||
p = tmp = malloc(len);
|
||||
strncpy(p, name, len - 1);
|
||||
} else {
|
||||
p = (char *) name;
|
||||
}
|
||||
|
||||
for (base = p; *p; p++)
|
||||
if (*p == '/')
|
||||
base = p + 1;
|
||||
|
||||
return base;
|
||||
}
|
||||
|
||||
const char *
|
||||
dirname(const char *name)
|
||||
{
|
||||
static char *ret = NULL;
|
||||
int len;
|
||||
int size = 0;
|
||||
const char *p;
|
||||
|
||||
if (ret) {
|
||||
free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
if (!name || !strcmp(name, "") || !strstr(name, "/"))
|
||||
return(".");
|
||||
|
||||
if (!strcmp(name, "/"))
|
||||
return(name);
|
||||
|
||||
// find the last slash in the string
|
||||
|
||||
len = strlen(name);
|
||||
p = &name[len - 1];
|
||||
|
||||
if (*p == '/') p--; // skip the trailing /
|
||||
|
||||
while (p != name && *p != '/') p--;
|
||||
|
||||
size = p - name;
|
||||
if (size) {
|
||||
ret = malloc(size + 1);
|
||||
memcpy(ret, name, size);
|
||||
ret[size] = '\0';
|
||||
} else if (*p == '/')
|
||||
return "/";
|
||||
else
|
||||
return "";
|
||||
|
||||
return (const char *) ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,4 +9,7 @@
|
|||
char *canonicalize_pathname(char *path);
|
||||
char *absolute_pathname(char *string, char *dot_path);
|
||||
|
||||
const char *basename(const char *name);
|
||||
const char *dirname(const char *name);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ Modified: 2000 AlansFixes
|
|||
#include <cktaccept.h>
|
||||
#include <trandefs.h>
|
||||
#include <sperror.h>
|
||||
#include "fteext.h"
|
||||
|
||||
#ifdef XSPICE
|
||||
/* gtri - add - wbk - Add headers */
|
||||
|
|
@ -40,12 +41,13 @@ void SetAnalyse( char * Analyse, int Percent);
|
|||
// some limitations.
|
||||
static bool AlmostEqualUlps(float A, float B, int maxUlps)
|
||||
{
|
||||
int intDiff;
|
||||
assert(sizeof(float) == sizeof(int));
|
||||
|
||||
if (A == B)
|
||||
return TRUE;
|
||||
|
||||
int intDiff = abs(*(int*)&A - *(int*)&B);
|
||||
intDiff = abs(*(int*)&A - *(int*)&B);
|
||||
|
||||
if (intDiff <= maxUlps)
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -15,12 +15,13 @@ Modified: Apr 2000 - Paolo Nenzi
|
|||
// some limitations.
|
||||
static bool AlmostEqualUlps(float A, float B, int maxUlps)
|
||||
{
|
||||
int intDiff;
|
||||
assert(sizeof(float) == sizeof(int));
|
||||
|
||||
if (A == B)
|
||||
return TRUE;
|
||||
|
||||
int intDiff = abs(*(int*)&A - *(int*)&B);
|
||||
intDiff = abs(*(int*)&A - *(int*)&B);
|
||||
|
||||
if (intDiff <= maxUlps)
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -18,12 +18,13 @@ Author: 1985 Thomas L. Quarles
|
|||
// some limitations.
|
||||
static bool AlmostEqualUlps(float A, float B, int maxUlps)
|
||||
{
|
||||
int intDiff;
|
||||
assert(sizeof(float) == sizeof(int));
|
||||
|
||||
if (A == B)
|
||||
return TRUE;
|
||||
|
||||
int intDiff = abs(*(int*)&A - *(int*)&B);
|
||||
intDiff = abs(*(int*)&A - *(int*)&B);
|
||||
|
||||
if (intDiff <= maxUlps)
|
||||
return TRUE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue