A few baby steps toward getting closer to the coding standard

This commit is contained in:
Gregory Nutt 2014-11-01 18:06:28 -06:00
parent aecac67593
commit 02b974859c
7 changed files with 1786 additions and 1444 deletions

File diff suppressed because it is too large Load Diff

View File

@ -100,7 +100,7 @@ static struct Value *bin(struct Value *v, unsigned long int value, long int digi
{
char buf[sizeof(long int)*8+1];
char *s;
Value_new_STRING(v);
s=buf+sizeof(buf);
*--s='\0';
@ -133,7 +133,7 @@ static struct Value *find(struct Value *v, struct String *pattern, long int occu
struct dirent *ent;
int currentdir;
int found=0;
Value_new_STRING(v);
String_new(&dirname);
String_new(&basename);
@ -418,7 +418,7 @@ static struct Value *fn_cvi(struct Value *v, struct Auto *stack) /*{{{*/
struct String *s=stringValue(stack,0);
long int n=(s->length && s->character[s->length-1]<0) ? -1 : 0;
int i;
for (i=s->length-1; i>=0; --i) n=(n<<8)|(s->character[i]&0xff);
return Value_new_INTEGER(v,n);
}
@ -508,7 +508,7 @@ static struct Value *fn_edit(struct Value *v, struct Auto *stack) /*{{{*/
if ((code&16) && ((*rd==' ') || (*rd=='\t')))
{
*wr++=' ';
while (rd<end && (*rd==' ' || *rd=='\t')) ++rd;
while (rd<end && (*rd==' ' || *rd=='\t')) ++rd;
continue;
}
@ -1377,7 +1377,7 @@ static struct Value *fn_timer(struct Value *v, struct Auto *stack) /*{{{*/
static struct Value *fn_tl(struct Value *v, struct Auto *stack) /*{{{*/
{
struct String *s=stringValue(stack,0);
Value_new_STRING(v);
if (s->length)
{
@ -1408,7 +1408,7 @@ static struct Value *fn_val(struct Value *v, struct Auto *stack) /*{{{*/
char *end;
long int i;
int overflow;
if (s->character==(char*)0) return Value_new_REAL(v,0.0);
i=Value_vali(s->character,&end,&overflow);
if (*end=='\0') return Value_new_INTEGER(v,i);

View File

@ -1,3 +1,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
#undef _POSIX_SOURCE
#define _POSIX_SOURCE 1
#undef _POSIX_C_SOURCE
@ -24,7 +28,9 @@
#include "bas.h"
/*}}}*/
/****************************************************************************
* Public Functions
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])

View File

@ -323,7 +323,7 @@ struct Value *Program_merge(struct Program *this, int dev, struct Value *value)
struct Token *line;
++l;
if (l!=1 || s.character[0]!='#')
if (l!=1 || s.character[0]!='#')
{
line=Token_newCode(s.character);
if (line->type==T_INTEGER && line->u.integer>0) Program_store(this,line,this->numbered?line->u.integer:0);

View File

@ -54,7 +54,7 @@ struct Value *stmt_CASE(struct Value *value) /*{{{*/
*nextcasevalue=pc;
if (pass==COMPILE) pc.token->u.casevalue->endselect=selectcase->token->u.selectcase->endselect;
pc.token->u.casevalue->nextcasevalue.line=-1;
++pc.token;
++pc.token;
switch (statementpc.token->type)
{
case T_CASEELSE: break;
@ -85,7 +85,7 @@ struct Value *stmt_CASE(struct Value *value) /*{{{*/
pc=exprpc;
return value;
}
Value_destroy(value);
Value_destroy(value);
}
/*}}}*/
else /* value or range */ /*{{{*/
@ -556,7 +556,7 @@ struct Value *stmt_DIM(struct Value *value) /*{{{*/
*var=newarray;
free(geometry);
}
if (pc.token->type==T_COMMA) ++pc.token; /* advance to next var */
if (pc.token->type==T_COMMA) ++pc.token; /* advance to next var */
else break;
}
return (struct Value*)0;
@ -655,7 +655,7 @@ struct Value *stmt_EDIT(struct Value *value) /*{{{*/
{ "joe", "+%ld " },
{ "modeori", "-l%ld " },
{ "origami", "-l%ld " },
{ "vi", "-c%ld " },
{ "vi", "-c%ld " },
{ "vim", "+%ld " },
{ "xemacs", "+%ld " }
};
@ -789,7 +789,7 @@ struct Value *stmt_END(struct Value *value) /*{{{*/
struct Token *eol;
for (eol=pc.token; eol->type!=T_EOL; ++eol);
pc.token->u.endpc=pc;
pc.token->u.endpc.token=eol;
++pc.token;
@ -1202,7 +1202,7 @@ struct Value *stmt_GET_PUT(struct Value *value) /*{{{*/
int put=pc.token->type==T_PUT;
long int chn;
struct Pc errpc;
++pc.token;
if (pc.token->type==T_CHANNEL) ++pc.token;
if (eval(value,_("channel"))->type==V_ERROR || Value_retype(value,V_INTEGER)->type==V_ERROR) return value;
@ -1556,7 +1556,7 @@ struct Value *stmt_LOCATE(struct Value *value) /*{{{*/
if (eval(value,_("row"))->type==V_ERROR || Value_retype(value,V_INTEGER)->type==V_ERROR) return value;
line=value->u.integer;
Value_destroy(value);
if (pass==INTERPRET && line<1)
if (pass==INTERPRET && line<1)
{
pc=argpc;
return Value_new_ERROR(value,OUTOFRANGE,_("row"));
@ -1567,7 +1567,7 @@ struct Value *stmt_LOCATE(struct Value *value) /*{{{*/
if (eval(value,_("column"))->type==V_ERROR || Value_retype(value,V_INTEGER)->type==V_ERROR) return value;
column=value->u.integer;
Value_destroy(value);
if (pass==INTERPRET && column<1)
if (pass==INTERPRET && column<1)
{
pc=argpc;
return Value_new_ERROR(value,OUTOFRANGE,_("column"));
@ -1716,7 +1716,7 @@ struct Value *stmt_IDENTIFIER(struct Value *value) /*{{{*/
if (pass!=INTERPRET) Value_destroy(value);
}
}
return (struct Value*)0;
}
/*}}}*/
@ -2796,7 +2796,7 @@ struct Value *stmt_OPEN(struct Value *value) /*{{{*/
}
}
Value_destroy(value);
if (pass==INTERPRET && inout==-1)
if (pass==INTERPRET && inout==-1)
{
pc=errpc;
return Value_new_ERROR(value,BADMODE);
@ -3042,7 +3042,7 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value) /*{{{*/
{
struct Pc usingpc;
usingpc=pc;
usingpc=pc;
printusing=1;
++pc.token;
if (pc.token->type==T_INTEGER)
@ -3386,7 +3386,7 @@ struct Value *stmt_RUN(struct Value *value) /*{{{*/
if (Program_beginning(&program,&begin)==(struct Pc*)0)
{
return Value_new_ERROR(value,NOPROGRAM);
}
}
}
else Value_destroy(value);
}
@ -3986,7 +3986,7 @@ struct Value *stmt_WRITE(struct Value *value) /*{{{*/
/*}}}*/
while (1)
{
if (eval(value,(const char*)0))
if (eval(value,(const char*)0))
{
if (value->type==V_ERROR) return value;
if (pass==INTERPRET)

View File

@ -33,7 +33,7 @@
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
* if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
@ -50,7 +50,7 @@ typedef uint32_t flex_uint32_t;
typedef signed char flex_int8_t;
typedef short int flex_int16_t;
typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
@ -176,7 +176,7 @@ extern FILE *yyin, *yyout;
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
do \
@ -233,7 +233,7 @@ struct yy_buffer_state
int yy_bs_lineno; /**< The line count. */
int yy_bs_column; /**< The column count. */
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
@ -1646,7 +1646,7 @@ YY_DECL
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
if ( !(yy_init) )
{
(yy_init) = 1;
@ -3629,7 +3629,7 @@ YY_RULE_SETUP
{
cur->statement=stmt_QUOTE_REM;
strcpy(cur->u.rem=malloc(strlen(yytext+1)+1),yytext+1);
}
}
return T_QUOTE;
}
YY_BREAK
@ -3989,7 +3989,7 @@ static int yy_get_next_buffer (void)
{
register yy_state_type yy_current_state;
register char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
@ -4049,7 +4049,7 @@ static int yy_get_next_buffer (void)
{
int c;
*(yy_c_buf_p) = (yy_hold_char);
if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
@ -4116,12 +4116,12 @@ static int yy_get_next_buffer (void)
/** Immediately switch to a different input stream.
* @param input_file A readable stream.
*
*
* @note This function does not reset the start condition to @c INITIAL .
*/
void yyrestart (FILE * input_file )
{
if ( ! YY_CURRENT_BUFFER ){
yyensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
@ -4134,11 +4134,11 @@ static int yy_get_next_buffer (void)
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
*
*
*/
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
{
/* TODO. We should be able to replace this entire function body
* with
* yypop_buffer_state();
@ -4178,13 +4178,13 @@ static void yy_load_buffer_state (void)
/** Allocate and initialize an input buffer state.
* @param file A readable stream.
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
*
*
* @return the allocated buffer state.
*/
YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@ -4207,11 +4207,11 @@ static void yy_load_buffer_state (void)
/** Destroy the buffer.
* @param b a buffer created with yy_create_buffer()
*
*
*/
void yy_delete_buffer (YY_BUFFER_STATE b )
{
if ( ! b )
return;
@ -4232,7 +4232,7 @@ static void yy_load_buffer_state (void)
{
int oerrno = errno;
yy_flush_buffer(b );
b->yy_input_file = file;
@ -4248,13 +4248,13 @@ static void yy_load_buffer_state (void)
}
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
errno = oerrno;
}
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
*
*
*/
void yy_flush_buffer (YY_BUFFER_STATE b )
{
@ -4283,7 +4283,7 @@ static void yy_load_buffer_state (void)
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
*
*
*/
void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
{
@ -4313,7 +4313,7 @@ void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
/** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
*
*
*/
void yypop_buffer_state (void)
{
@ -4337,7 +4337,7 @@ void yypop_buffer_state (void)
static void yyensure_buffer_stack (void)
{
yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
/* First allocation is just for 2 elements, since we don't know if this
@ -4350,7 +4350,7 @@ static void yyensure_buffer_stack (void)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
@ -4380,13 +4380,13 @@ static void yyensure_buffer_stack (void)
/** Setup the input buffer state to scan directly from a user-specified character buffer.
* @param base the character buffer
* @param size the size in bytes of the character buffer
*
* @return the newly allocated buffer state object.
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
{
YY_BUFFER_STATE b;
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
@ -4415,14 +4415,14 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
*
*
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
* yy_scan_bytes() instead.
*/
YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
{
return yy_scan_bytes(yystr,strlen(yystr) );
}
@ -4430,7 +4430,7 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
@ -4439,7 +4439,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
char *buf;
yy_size_t n;
yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
buf = (char *) yyalloc(n );
@ -4493,16 +4493,16 @@ static void yy_fatal_error (yyconst char* msg )
/* Accessor methods (get/set functions) to struct members. */
/** Get the current line number.
*
*
*/
int yyget_lineno (void)
{
return yylineno;
}
/** Get the input stream.
*
*
*/
FILE *yyget_in (void)
{
@ -4510,7 +4510,7 @@ FILE *yyget_in (void)
}
/** Get the output stream.
*
*
*/
FILE *yyget_out (void)
{
@ -4518,7 +4518,7 @@ FILE *yyget_out (void)
}
/** Get the length of the current token.
*
*
*/
yy_size_t yyget_leng (void)
{
@ -4526,7 +4526,7 @@ yy_size_t yyget_leng (void)
}
/** Get the current token.
*
*
*/
char *yyget_text (void)
@ -4536,18 +4536,18 @@ char *yyget_text (void)
/** Set the current line number.
* @param line_number
*
*
*/
void yyset_lineno (int line_number )
{
yylineno = line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param in_str A readable stream.
*
*
* @see yy_switch_to_buffer
*/
void yyset_in (FILE * in_str )
@ -4601,7 +4601,7 @@ static int yy_init_globals (void)
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy (void)
{
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
yy_delete_buffer(YY_CURRENT_BUFFER );
@ -5182,7 +5182,7 @@ struct String *Token_toString(struct Token *token, struct Token *spaceto, struct
++thisnotindent; ++nextindent;
}
break;
}
}
case T_SELECTCASE: thisnotindent+=2; nextindent+=2; break;
case T_EQ:
{

View File

@ -1284,7 +1284,7 @@ struct Value *Value_toStringUsing(struct Value *this, struct String *s, struct S
goto work;
}
else
{
{
Value_destroy(this);
return Value_new_ERROR(this,IOERROR,_("unpaired \\ in format"));
}
@ -1340,17 +1340,17 @@ struct Value *Value_toStringUsing(struct Value *this, struct String *s, struct S
}
}
if (*usingpos<using->length && using->character[*usingpos]=='-' )
{
{
++(*usingpos);
if (headingsign==0) headingsign=2;
trailingsign=-1;
}
}
else if (*usingpos<using->length && using->character[*usingpos]=='+')
{
{
++(*usingpos);
if (headingsign==0) headingsign=2;
trailingsign=1;
}
}
while (*usingpos<using->length && using->character[*usingpos]=='^')
{
++(*usingpos);
@ -1405,7 +1405,7 @@ struct String *Value_toWrite(struct Value *this, struct String *s) /*{{{*/
switch (this->type)
{
case V_INTEGER: String_appendPrintf(s,"%ld",this->u.integer); break;
case V_REAL:
case V_REAL:
{
double x;
int p=DBL_DIG;
@ -1427,7 +1427,7 @@ struct String *Value_toWrite(struct Value *this, struct String *s) /*{{{*/
{
size_t l=this->u.string.length;
char *data=this->u.string.character;
String_appendChar(s,'"');
while (l--)
{