Subversion Repositories SvarDOS

Rev

Rev 1293 | Rev 1299 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1293 Rev 1298
Line 38... Line 38...
38
#include <i86.h>
38
#include <i86.h>
39
typedef unsigned short FHANDLE;
39
typedef unsigned short FHANDLE;
40
 
40
 
41
#endif
41
#endif
42
 
42
 
43
#include <stdlib.h>  /* NULL */
-
 
-
 
43
 
44
#include <string.h>  /* memcmp(), strcpy() */
44
#include <string.h>  /* strcpy() */
45
 
45
 
46
#include "svarlang.h"
46
#include "svarlang.h"
47
 
47
 
48
 
48
 
49
/* supplied through DEFLANG.C */
49
/* supplied through DEFLANG.C */
50
extern char svarlang_mem[];
50
extern char svarlang_mem[];
51
extern unsigned short svarlang_dict[];
51
extern unsigned short svarlang_dict[];
52
extern const unsigned short svarlang_memsz;
52
extern const unsigned short svarlang_memsz;
53
extern const unsigned short svarlang_string_count;
53
extern const unsigned short svarlang_string_count;
54
 
54
 
-
 
55
 
55
const char *svarlang_strid(unsigned short id) {
56
const char *svarlang_strid(unsigned short id) {
56
   size_t left = 0, right = svarlang_string_count - 1, x;
57
  size_t left = 0, right = svarlang_string_count - 1, x;
57
   unsigned short v;
58
  unsigned short v;
-
 
59
 
-
 
60
  if (svarlang_string_count == 0) return("");
-
 
61
 
-
 
62
  while (left <= right) {
-
 
63
    x = left + ( (right - left ) >> 2 );
-
 
64
    v = svarlang_dict[x * 2];
-
 
65
 
-
 
66
    if (id == v) return(svarlang_mem + svarlang_dict[x * 2 + 1]);
58
 
67
 
-
 
68
    if (id > v) {
-
 
69
      left = x + 1;
-
 
70
    } else {
59
   if (svarlang_string_count == 0) return "";
71
      right = x - 1;
-
 
72
    }
-
 
73
  }
60
 
74
 
61
   while (left <= right ) {
-
 
62
      x = left + ( (right - left ) >> 2 );
-
 
63
      v = svarlang_dict[x * 2];
-
 
64
      if ( id == v )  {
-
 
65
        return svarlang_mem + svarlang_dict[x * 2 + 1];
-
 
66
      }
-
 
67
      else if ( id > v ) left = x + 1;
-
 
68
      else right = x - 1;
-
 
69
   }
-
 
70
   return "";
75
  return("");
71
}
76
}
72
 
77
 
73
 
78
 
74
/* routines below are simplified (dos-based) versions of the libc FILE-related
79
/* routines below are simplified (dos-based) versions of the libc FILE-related
75
 * functions. Using them avoids a dependency on FILE, hence makes the binary
80
 * functions. Using them avoids a dependency on FILE, hence makes the binary