projects
/
vg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
error limit
[vg.git]
/
vg_platform.h
diff --git
a/vg_platform.h
b/vg_platform.h
index 98baef896a60196c0a85521e9f6ea3386120bf99..b04ce672b9afa8d0803dec16dffb7f5bcbc48c77 100644
(file)
--- a/
vg_platform.h
+++ b/
vg_platform.h
@@
-39,6
+39,14
@@
struct vg_achievement
#define vg_list_size( A ) (sizeof(A)/sizeof(A[0]))
#define VG_MUST_USE_RESULT __attribute__((warn_unused_result))
#define vg_list_size( A ) (sizeof(A)/sizeof(A[0]))
#define VG_MUST_USE_RESULT __attribute__((warn_unused_result))
+#include <stdio.h>
+#include <dirent.h>
+#include <string.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <math.h>
+#include <assert.h>
+
enum strncpy_behaviour{
k_strncpy_always_add_null = 0,
k_strncpy_allow_cutoff = 1,
enum strncpy_behaviour{
k_strncpy_always_add_null = 0,
k_strncpy_allow_cutoff = 1,
@@
-77,6
+85,7
@@
struct vg_str{
VG_STATIC void vg_strnull( vg_str *str, char *buffer, u32 len )
{
str->buffer = buffer;
VG_STATIC void vg_strnull( vg_str *str, char *buffer, u32 len )
{
str->buffer = buffer;
+ str->buffer[0] = '\0';
str->i = 0;
str->len = len;
}
str->i = 0;
str->len = len;
}
@@
-96,10
+105,18
@@
VG_STATIC int vg_strgood( vg_str *str )
if( str->buffer[str->i -1] == '\0' ) return 1;
else return 0;
}
if( str->buffer[str->i -1] == '\0' ) return 1;
else return 0;
}
- else{
- str->buffer[ str->i ++ ] = '\0';
- return 1;
+ else return 1;
+}
+
+VG_STATIC char *vg_strch( vg_str *str, char c )
+{
+ char *ptr = NULL;
+ for( u32 i=0; i<str->i; i++ ){
+ if( str->buffer[i] == c )
+ ptr = str->buffer+i;
}
}
+
+ return ptr;
}
VG_STATIC u32 vg_strdjb2( const char *str )
}
VG_STATIC u32 vg_strdjb2( const char *str )
@@
-112,14
+129,6
@@
VG_STATIC u32 vg_strdjb2( const char *str )
return hash;
}
return hash;
}
-#include <stdio.h>
-#include <dirent.h>
-#include <string.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <math.h>
-#include <assert.h>
-
#define VG_MIN( A, B ) ((A)<(B)?(A):(B))
#define VG_MAX( A, B ) ((A)>(B)?(A):(B))
#endif
#define VG_MIN( A, B ) ((A)<(B)?(A):(B))
#define VG_MAX( A, B ) ((A)>(B)?(A):(B))
#endif