[Olsr-cvs] olsrd-current/lib/tas/src/lua lapi.c, 1.1, 1.2 lauxlib.c, 1.1, 1.2 lauxlib.h, 1.1, 1.2 lbaselib.c, 1.1, 1.2 ldebug.c, 1.1, 1.2 ldebug.h, 1.1, 1.2 ldo.h, 1.1, 1.2 liolib.c, 1.1, 1.2 llex.c, 1.1, 1.2 llex.h, 1.1, 1.2 lparser.c, 1.1, 1.2 lua.h, 1.1, 1.2 lundump.c, 1.1, 1.2

Bernd Petrovitsch (spam-protected)
Fri Apr 20 15:46:06 CEST 2007


Update of /cvsroot/olsrd/olsrd-current/lib/tas/src/lua
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30814/lib/tas/src/lua

Modified Files:
	lapi.c lauxlib.c lauxlib.h lbaselib.c ldebug.c ldebug.h ldo.h 
	liolib.c llex.c llex.h lparser.c lua.h lundump.c 
Log Message:
cleanup, 1. step (to get some local changes away):
* killed lots of warnings
* added __attribure__((unused)) and __attribure__((format(printf, ..., ...)))
* added "const"
* moved declarations of static functions into .c files
* added "static" declarations
* removed all "inline" declarations. Usually the compiler knows better anyways.
* removed emtpy "return" statements at the end of functions
* localized declarations
* avoided unnecessary data copies
* removed lots of empty lines
There is much more to do.



Index: liolib.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/liolib.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** liolib.c	12 Apr 2005 17:17:26 -0000	1.1
--- liolib.c	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 51,54 ****
--- 51,56 ----
  
  
+ static int io_exit (lua_State *L) __attribute__((noreturn));
+ 
  
  /*
***************
*** 556,563 ****
  
  
  static int io_tmpname (lua_State *L) {
  #if !USE_TMPNAME
    luaL_error(L, "`tmpname' not supported");
-   return 0;
  #else
    char buff[L_tmpnam];
--- 558,570 ----
  
  
+ #if !USE_TMPNAME
+ static int io_tmpname (lua_State *L) __attribute__((noreturn));
+ #else
+ static int io_tmpname (lua_State *L);
+ #endif
+ 
  static int io_tmpname (lua_State *L) {
  #if !USE_TMPNAME
    luaL_error(L, "`tmpname' not supported");
  #else
    char buff[L_tmpnam];
***************
*** 715,719 ****
  static int io_exit (lua_State *L) {
    exit(luaL_optint(L, 1, EXIT_SUCCESS));
-   return 0;  /* to avoid warnings */
  }
  
--- 722,725 ----

Index: ldo.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/ldo.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ldo.h	12 Apr 2005 17:17:26 -0000	1.1
--- ldo.h	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 54,58 ****
  void luaD_growstack (lua_State *L, int n);
  
! void luaD_throw (lua_State *L, int errcode);
  int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
  
--- 54,58 ----
  void luaD_growstack (lua_State *L, int n);
  
! void luaD_throw (lua_State *L, int errcode) __attribute__((noreturn));
  int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
  

Index: lua.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/lua.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lua.h	12 Apr 2005 17:17:27 -0000	1.1
--- lua.h	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 214,218 ****
  LUA_API const char *lua_version (void);
  
! LUA_API int   lua_error (lua_State *L);
  
  LUA_API int   lua_next (lua_State *L, int idx);
--- 214,218 ----
  LUA_API const char *lua_version (void);
  
! LUA_API int   lua_error (lua_State *L) __attribute__((noreturn));
  
  LUA_API int   lua_next (lua_State *L, int idx);

Index: llex.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/llex.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** llex.h	12 Apr 2005 17:17:26 -0000	1.1
--- llex.h	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 68,73 ****
  int luaX_lex (LexState *LS, SemInfo *seminfo);
  void luaX_checklimit (LexState *ls, int val, int limit, const char *msg);
! void luaX_syntaxerror (LexState *ls, const char *s);
! void luaX_errorline (LexState *ls, const char *s, const char *token, int line);
  const char *luaX_token2str (LexState *ls, int token);
  
--- 68,73 ----
  int luaX_lex (LexState *LS, SemInfo *seminfo);
  void luaX_checklimit (LexState *ls, int val, int limit, const char *msg);
! void luaX_syntaxerror (LexState *ls, const char *s) __attribute__((noreturn));
! void luaX_errorline (LexState *ls, const char *s, const char *token, int line) __attribute__((noreturn));
  const char *luaX_token2str (LexState *ls, int token);
  

Index: lauxlib.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/lauxlib.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lauxlib.h	12 Apr 2005 17:17:26 -0000	1.1
--- lauxlib.h	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 32,37 ****
  LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *e);
  LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *e);
! LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname);
! LUALIB_API int luaL_argerror (lua_State *L, int numarg, const char *extramsg);
  LUALIB_API const char *luaL_checklstring (lua_State *L, int numArg, size_t *l);
  LUALIB_API const char *luaL_optlstring (lua_State *L, int numArg,
--- 32,37 ----
  LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *e);
  LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *e);
! LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) __attribute__((noreturn));
! LUALIB_API int luaL_argerror (lua_State *L, int numarg, const char *extramsg) __attribute__((noreturn));
  LUALIB_API const char *luaL_checklstring (lua_State *L, int numArg, size_t *l);
  LUALIB_API const char *luaL_optlstring (lua_State *L, int numArg,
***************
*** 49,53 ****
  
  LUALIB_API void luaL_where (lua_State *L, int lvl);
! LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...);
  
  LUALIB_API int luaL_findstring (const char *st, const char *const lst[]);
--- 49,53 ----
  
  LUALIB_API void luaL_where (lua_State *L, int lvl);
! LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) __attribute__((noreturn));
  
  LUALIB_API int luaL_findstring (const char *st, const char *const lst[]);

Index: lundump.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/lundump.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lundump.c	12 Apr 2005 17:17:35 -0000	1.1
--- lundump.c	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 27,30 ****
--- 27,32 ----
  } LoadState;
  
+ static void unexpectedEOZ (LoadState* S) __attribute__((noreturn));
+ 
  static void unexpectedEOZ (LoadState* S)
  {

Index: llex.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/llex.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** llex.c	12 Apr 2005 17:17:26 -0000	1.1
--- llex.c	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 22,28 ****
  
  
- 
  #define next(LS) (LS->current = zgetc(LS->z))
  
  
  
--- 22,29 ----
  
  
  #define next(LS) (LS->current = zgetc(LS->z))
  
+ static void luaX_error (LexState *ls, const char *s, const char *token) __attribute__((noreturn));
+ static void luaX_lexerror (LexState *ls, const char *s, int token) __attribute__((noreturn));
  
  
***************
*** 59,63 ****
  }
  
- 
  void luaX_errorline (LexState *ls, const char *s, const char *token, int line) {
    lua_State *L = ls->L;
--- 60,63 ----
***************
*** 68,72 ****
  }
  
- 
  static void luaX_error (LexState *ls, const char *s, const char *token) {
    luaX_errorline(ls, s, token, ls->linenumber);
--- 68,71 ----

Index: lparser.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/lparser.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lparser.c	12 Apr 2005 17:17:27 -0000	1.1
--- lparser.c	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 52,55 ****
--- 52,56 ----
  static void chunk (LexState *ls);
  static void expr (LexState *ls, expdesc *v);
+ static void error_expected (LexState *ls, int token) __attribute__((noreturn));
  
  

Index: lapi.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/lapi.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lapi.c	12 Apr 2005 17:17:26 -0000	1.1
--- lapi.c	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 806,810 ****
    luaG_errormsg(L);
    lua_unlock(L);
-   return 0;  /* to avoid warnings */
  }
  
--- 806,809 ----

Index: ldebug.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/ldebug.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ldebug.h	12 Apr 2005 17:17:26 -0000	1.1
--- ldebug.h	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 20,29 ****
  
  void luaG_inithooks (lua_State *L);
! void luaG_typeerror (lua_State *L, const TObject *o, const char *opname);
! void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
! void luaG_aritherror (lua_State *L, const TObject *p1, const TObject *p2);
! int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2);
! void luaG_runerror (lua_State *L, const char *fmt, ...);
! void luaG_errormsg (lua_State *L);
  int luaG_checkcode (const Proto *pt);
  
--- 20,29 ----
  
  void luaG_inithooks (lua_State *L);
! void luaG_typeerror (lua_State *L, const TObject *o, const char *opname) __attribute__((noreturn));
! void luaG_concaterror (lua_State *L, StkId p1, StkId p2) __attribute__((noreturn));
! void luaG_aritherror (lua_State *L, const TObject *p1, const TObject *p2) __attribute__((noreturn));
! int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) __attribute__((noreturn));
! void luaG_runerror (lua_State *L, const char *fmt, ...) __attribute__((noreturn));
! void luaG_errormsg (lua_State *L) __attribute__((noreturn));
  int luaG_checkcode (const Proto *pt);
  

Index: lbaselib.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/lbaselib.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lbaselib.c	12 Apr 2005 17:17:26 -0000	1.1
--- lbaselib.c	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 76,80 ****
  }
  
! 
  static int luaB_error (lua_State *L) {
    int level = luaL_optint(L, 2, 1);
--- 76,80 ----
  }
  
! static int luaB_error (lua_State *L)  __attribute__((noreturn));
  static int luaB_error (lua_State *L) {
    int level = luaL_optint(L, 2, 1);
***************
*** 87,91 ****
      lua_concat(L, 2);
    }
!   return lua_error(L);
  }
  
--- 87,91 ----
      lua_concat(L, 2);
    }
!   lua_error(L);
  }
  

Index: ldebug.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/ldebug.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ldebug.c	12 Apr 2005 17:17:26 -0000	1.1
--- ldebug.c	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 548,552 ****
    else
      luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
-   return 0;
  }
  
--- 548,551 ----

Index: lauxlib.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/lua/lauxlib.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** lauxlib.c	12 Apr 2005 17:17:26 -0000	1.1
--- lauxlib.c	20 Apr 2007 13:46:03 -0000	1.2
***************
*** 51,59 ****
      narg--;  /* do not count `self' */
      if (narg == 0)  /* error is in the self argument itself? */
!       return luaL_error(L, "calling `%s' on bad self (%s)", ar.name, extramsg);
    }
    if (ar.name == NULL)
      ar.name = "?";
!   return luaL_error(L, "bad argument #%d to `%s' (%s)",
                          narg, ar.name, extramsg);
  }
--- 51,59 ----
      narg--;  /* do not count `self' */
      if (narg == 0)  /* error is in the self argument itself? */
!       luaL_error(L, "calling `%s' on bad self (%s)", ar.name, extramsg);
    }
    if (ar.name == NULL)
      ar.name = "?";
!   luaL_error(L, "bad argument #%d to `%s' (%s)",
                          narg, ar.name, extramsg);
  }
***************
*** 63,70 ****
    const char *msg = lua_pushfstring(L, "%s expected, got %s",
                                      tname, lua_typename(L, lua_type(L,narg)));
!   return luaL_argerror(L, narg, msg);
  }
  
  
  static void tag_error (lua_State *L, int narg, int tag) {
    luaL_typerror(L, narg, lua_typename(L, tag)); 
--- 63,71 ----
    const char *msg = lua_pushfstring(L, "%s expected, got %s",
                                      tname, lua_typename(L, lua_type(L,narg)));
!   luaL_argerror(L, narg, msg);
  }
  
  
+ static void tag_error (lua_State *L, int narg, int tag) __attribute__((noreturn));
  static void tag_error (lua_State *L, int narg, int tag) {
    luaL_typerror(L, narg, lua_typename(L, tag)); 
***************
*** 92,96 ****
    va_end(argp);
    lua_concat(L, 2);
!   return lua_error(L);
  }
  
--- 93,97 ----
    va_end(argp);
    lua_concat(L, 2);
!   lua_error(L);
  }
  





More information about the Olsr-cvs mailing list