File: IntStr.c

package info (click to toggle)
oo2c32 1.5.0-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 8,748 kB
  • ctags: 5,415
  • sloc: ansic: 95,007; sh: 473; makefile: 344; perl: 57; lisp: 21
file content (88 lines) | stat: -rw-r--r-- 1,874 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* file generated by oo2c -- do not edit */
#include "__oo2c.h"
#include "__libc.h"
#include "IntStr.d"

static _ModId _mid;

void IntStr__StrToInt(const unsigned char* str__ref, int str_0d, int *int_, signed char *res) {
  register int i0;
  unsigned char* str;
  char* _old_top_vs = _top_vs;
  _push_value(int, str, str__ref, str_0d);
  i0 = IntConv__FormatInt((const unsigned char*)(int)str, str_0d);
  *res = i0;
  i0 = *res;
  i0 = i0 != 0;
  if (i0) goto l0;
  i0 = IntConv__ValueInt((const unsigned char*)(int)str, str_0d);
  *int_ = i0;
l0:
  _top_vs = _old_top_vs;
}

void IntStr__Reverse(unsigned char* str, int str_0d, short int start, short int end) {
  register int i0, i1, i2, i3, i4, i5;
  i0 = start >= end;
  if (i0) goto l1;
  i5 = end;
  i4 = start;
l0:
  i0 = (int)str + i4;
  i1 = (int)str + i5;
  i2 = *(unsigned char*)i0;
  i3 = *(unsigned char*)i1;
  *(unsigned char*)i0 = i3;
  i4++;
  i0 = i5 - 1;
  *(unsigned char*)i1 = i2;
  i5 = i4 >= i0;
  if (i5) goto l1;
  i5 = i0;
  goto l0;
l1:
  ;
}

void IntStr__IntToStr(int int_, unsigned char* str, int str_0d) {
  register int i0, i1, i2, i3, i4, i5;
  unsigned char b[12];
  i0 = int_ == (-2147483647-1);
  if (i0) goto l4;
  i4 = int_ < 0;
  if (i4) goto l0;
  i1 = 0;
  i5 = int_;
  goto l1;
l0:
  *(unsigned char*)(int)b = 45;
  i5 = - int_;
  i1 = 1;
l1:
  i2 = i1;
l2:
  i0 = i2 + 1;
  _mod(i3, i5, 10, int);
  i3 += 48;
  _div(i5, i5, 10, int);
  i4 = (int)b + i2;
  *(unsigned char*)i4 = i3;
  i2 = i5 == 0;
  if (i2) goto l3;
  i2 = i0;
  goto l2;
l3:
  i4 = (int)b + i0;
  *(unsigned char*)i4 = 0;
  i4 = i0 - 1;
  IntStr__Reverse((unsigned char*)(int)b, 12, (short int)i1, (short int)i4);
  goto l5;
l4:
  (void)memcpy((void*) (int)b, (const void*) (int)_c0, 12);
l5:
  _string_copy((int)str, (int)b, str_0d);
}

void IntStr_init(void) {
  _mid = _register_module(&IntStr_md.md, NULL);
}