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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
|
/* Generated by Nim Compiler v1.6.14 */
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(x, y)
#define nimln_(x, y)
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct tyObject_PathIter__YUzFuNRt4M8JemjrCMySxA tyObject_PathIter__YUzFuNRt4M8JemjrCMySxA;
typedef struct tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct tyObject_PathIter__YUzFuNRt4M8JemjrCMySxA {
NI i;
NI prev;
NIM_BOOL notFirst;
};
struct tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ {
NI Field0;
NI Field1;
};
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, hasNext__pureZpathnorm_6)(tyObject_PathIter__YUzFuNRt4M8JemjrCMySxA it, NimStringDesc* x);
N_LIB_PRIVATE N_NIMCALL(tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ, next__pureZpathnorm_10)(tyObject_PathIter__YUzFuNRt4M8JemjrCMySxA* it, NimStringDesc* x);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isSlash__pureZpathnorm_63)(NimStringDesc* x, tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ bounds);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, addChar)(NimStringDesc* s, NIM_CHAR c);
N_LIB_PRIVATE N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isDotDot__pureZpathnorm_59)(NimStringDesc* x, tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ bounds);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, setLengthStr)(NimStringDesc* s, NI newLen);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, substr__system_7755)(NimStringDesc* s, NI first, NI last);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, copyMem__system_1733)(void* dest, void* source, NI size);
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, resizeString)(NimStringDesc* dest, NI addlen);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isDot__pureZpathnorm_55)(NimStringDesc* x, tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ bounds);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_NIMCALL(NimStringDesc*, rawNewString)(NI cap);
N_LIB_PRIVATE N_NIMCALL(void, addNormalizePath__pureZpathnorm_71)(NimStringDesc* x, NimStringDesc** result, NI* state, NIM_CHAR dirSep);
STRING_LITERAL(TM__DfU0iuayCGwHDN1Exp9cbKg_2, ".", 1);
static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size) {
void* T1_;
T1_ = (void*)0;
T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
nimSetMem__systemZmemory_7(p, ((int) 0), size);
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, hasNext__pureZpathnorm_6)(tyObject_PathIter__YUzFuNRt4M8JemjrCMySxA it, NimStringDesc* x) {
NIM_BOOL result;
result = (NIM_BOOL)0;
result = (it.i < (x ? x->Sup.len : 0));
return result;
}
N_LIB_PRIVATE N_NIMCALL(tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ, next__pureZpathnorm_10)(tyObject_PathIter__YUzFuNRt4M8JemjrCMySxA* it, NimStringDesc* x) {
tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ result;
nimZeroMem((void*)(&result), sizeof(tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ));
(*it).prev = (*it).i;
{
NIM_BOOL T3_;
T3_ = (NIM_BOOL)0;
T3_ = !((*it).notFirst);
if (!(T3_)) goto LA4_;
T3_ = (((NU8)(x->data[(*it).i])) == ((NU8)(47)) || ((NU8)(x->data[(*it).i])) == ((NU8)(47)));
LA4_: ;
if (!T3_) goto LA5_;
(*it).i += ((NI) 1);
}
goto LA1_;
LA5_: ;
{
{
while (1) {
NIM_BOOL T10_;
T10_ = (NIM_BOOL)0;
T10_ = ((*it).i < (x ? x->Sup.len : 0));
if (!(T10_)) goto LA11_;
T10_ = !((((NU8)(x->data[(*it).i])) == ((NU8)(47)) || ((NU8)(x->data[(*it).i])) == ((NU8)(47))));
LA11_: ;
if (!T10_) goto LA9;
(*it).i += ((NI) 1);
} LA9: ;
}
}
LA1_: ;
{
NI colontmp_;
NI colontmp__2;
if (!((*it).prev < (*it).i)) goto LA14_;
colontmp_ = (*it).prev;
colontmp__2 = (NI)((*it).i - ((NI) 1));
result.Field0 = colontmp_;
result.Field1 = colontmp__2;
}
goto LA12_;
LA14_: ;
{
NIM_BOOL T17_;
T17_ = (NIM_BOOL)0;
T17_ = hasNext__pureZpathnorm_6((*it), x);
if (!T17_) goto LA18_;
result = next__pureZpathnorm_10(it, x);
}
goto LA12_;
LA18_: ;
LA12_: ;
{
while (1) {
NIM_BOOL T22_;
T22_ = (NIM_BOOL)0;
T22_ = ((*it).i < (x ? x->Sup.len : 0));
if (!(T22_)) goto LA23_;
T22_ = (((NU8)(x->data[(*it).i])) == ((NU8)(47)) || ((NU8)(x->data[(*it).i])) == ((NU8)(47)));
LA23_: ;
if (!T22_) goto LA21;
(*it).i += ((NI) 1);
} LA21: ;
}
(*it).notFirst = NIM_TRUE;
return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isSlash__pureZpathnorm_63)(NimStringDesc* x, tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ bounds) {
NIM_BOOL result;
NIM_BOOL T1_;
result = (NIM_BOOL)0;
T1_ = (NIM_BOOL)0;
T1_ = (bounds.Field1 == bounds.Field0);
if (!(T1_)) goto LA2_;
T1_ = (((NU8)(x->data[bounds.Field0])) == ((NU8)(47)) || ((NU8)(x->data[bounds.Field0])) == ((NU8)(47)));
LA2_: ;
result = T1_;
return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isDotDot__pureZpathnorm_59)(NimStringDesc* x, tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ bounds) {
NIM_BOOL result;
NIM_BOOL T1_;
NIM_BOOL T2_;
result = (NIM_BOOL)0;
T1_ = (NIM_BOOL)0;
T2_ = (NIM_BOOL)0;
T2_ = (bounds.Field1 == (NI)(bounds.Field0 + ((NI) 1)));
if (!(T2_)) goto LA3_;
T2_ = ((NU8)(x->data[bounds.Field0]) == (NU8)(46));
LA3_: ;
T1_ = T2_;
if (!(T1_)) goto LA4_;
T1_ = ((NU8)(x->data[(NI)(bounds.Field0 + ((NI) 1))]) == (NU8)(46));
LA4_: ;
result = T1_;
return result;
}
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size) {
void* T1_;
T1_ = (void*)0;
T1_ = memcpy(dest, source, ((size_t) (size)));
}
static N_INLINE(void, copyMem__system_1733)(void* dest, void* source, NI size) {
nimCopyMem(dest, source, size);
}
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
{
if (!!((src == ((NimStringDesc*) NIM_NIL)))) goto LA3_;
copyMem__system_1733(((void*) ((&(*dest).data[(*dest).Sup.len]))), ((void*) ((*src).data)), ((NI) ((NI)((*src).Sup.len + ((NI) 1)))));
(*dest).Sup.len += (*src).Sup.len;
}
LA3_: ;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isDot__pureZpathnorm_55)(NimStringDesc* x, tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ bounds) {
NIM_BOOL result;
NIM_BOOL T1_;
result = (NIM_BOOL)0;
T1_ = (NIM_BOOL)0;
T1_ = (bounds.Field1 == bounds.Field0);
if (!(T1_)) goto LA2_;
T1_ = ((NU8)(x->data[bounds.Field0]) == (NU8)(46));
LA2_: ;
result = T1_;
return result;
}
N_LIB_PRIVATE N_NIMCALL(void, addNormalizePath__pureZpathnorm_71)(NimStringDesc* x, NimStringDesc** result, NI* state, NIM_CHAR dirSep) {
tyObject_PathIter__YUzFuNRt4M8JemjrCMySxA it;
nimZeroMem((void*)(&it), sizeof(tyObject_PathIter__YUzFuNRt4M8JemjrCMySxA));
it.notFirst = (((NI) 0) < (NI)((NI64)((*state)) >> (NU64)(((NI) 1))));
{
if (!it.notFirst) goto LA3_;
{
while (1) {
NIM_BOOL T7_;
T7_ = (NIM_BOOL)0;
T7_ = (it.i < (x ? x->Sup.len : 0));
if (!(T7_)) goto LA8_;
T7_ = (((NU8)(x->data[it.i])) == ((NU8)(47)) || ((NU8)(x->data[it.i])) == ((NU8)(47)));
LA8_: ;
if (!T7_) goto LA6;
it.i += ((NI) 1);
} LA6: ;
}
}
LA3_: ;
{
while (1) {
NIM_BOOL T11_;
tyTuple__1v9bKyksXWMsm0vNwmZ4EuQ b;
T11_ = (NIM_BOOL)0;
T11_ = hasNext__pureZpathnorm_6(it, x);
if (!T11_) goto LA10;
b = next__pureZpathnorm_10((&it), x);
{
NIM_BOOL T14_;
T14_ = (NIM_BOOL)0;
T14_ = ((NI)((NI64)((*state)) >> (NU64)(((NI) 1))) == ((NI) 0));
if (!(T14_)) goto LA15_;
T14_ = isSlash__pureZpathnorm_63(x, b);
LA15_: ;
if (!T14_) goto LA16_;
{
NIM_BOOL T20_;
T20_ = (NIM_BOOL)0;
T20_ = (((*result) ? (*result)->Sup.len : 0) == ((NI) 0));
if (T20_) goto LA21_;
T20_ = !((((NU8)((*result)->data[(NI)(((*result) ? (*result)->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)) || ((NU8)((*result)->data[(NI)(((*result) ? (*result)->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47))));
LA21_: ;
if (!T20_) goto LA22_;
unsureAsgnRef((void**) (&(*result)), addChar((*result), dirSep));
}
LA22_: ;
(*state) = (NI)((*state) | ((NI) 1));
}
goto LA12_;
LA16_: ;
{
NIM_BOOL T25_;
T25_ = (NIM_BOOL)0;
T25_ = isDotDot__pureZpathnorm_59(x, b);
if (!T25_) goto LA26_;
{
NI d;
if (!(((NI) 1) <= (NI)((NI64)((*state)) >> (NU64)(((NI) 1))))) goto LA30_;
d = ((*result) ? (*result)->Sup.len : 0);
{
while (1) {
NIM_BOOL T34_;
T34_ = (NIM_BOOL)0;
T34_ = ((NI)((*state) & ((NI) 1)) < (NI)(d - ((NI) 1)));
if (!(T34_)) goto LA35_;
T34_ = !((((NU8)((*result)->data[(NI)(d - ((NI) 1))])) == ((NU8)(47)) || ((NU8)((*result)->data[(NI)(d - ((NI) 1))])) == ((NU8)(47))));
LA35_: ;
if (!T34_) goto LA33;
d -= ((NI) 1);
} LA33: ;
}
{
if (!(((NI) 0) < d)) goto LA38_;
unsureAsgnRef((void**) (&(*result)), setLengthStr((*result), ((NI) ((NI)(d - ((NI) 1))))));
(*state) -= ((NI) 2);
}
LA38_: ;
}
goto LA28_;
LA30_: ;
{
NimStringDesc* T47_;
{
NIM_BOOL T43_;
T43_ = (NIM_BOOL)0;
T43_ = (((NI) 0) < ((*result) ? (*result)->Sup.len : 0));
if (!(T43_)) goto LA44_;
T43_ = !((((NU8)((*result)->data[(NI)(((*result) ? (*result)->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)) || ((NU8)((*result)->data[(NI)(((*result) ? (*result)->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47))));
LA44_: ;
if (!T43_) goto LA45_;
unsureAsgnRef((void**) (&(*result)), addChar((*result), dirSep));
}
LA45_: ;
T47_ = NIM_NIL;
T47_ = substr__system_7755(x, b.Field0, b.Field1);
unsureAsgnRef((void**) (&(*result)), resizeString((*result), (T47_ ? T47_->Sup.len : 0) + 0));
appendString((*result), T47_);
}
LA28_: ;
}
goto LA12_;
LA26_: ;
{
NIM_BOOL T49_;
T49_ = (NIM_BOOL)0;
T49_ = isDot__pureZpathnorm_55(x, b);
if (!T49_) goto LA50_;
}
goto LA12_;
LA50_: ;
{
NimStringDesc* T61_;
if (!(b.Field0 <= b.Field1)) goto LA53_;
{
NIM_BOOL T57_;
T57_ = (NIM_BOOL)0;
T57_ = (((NI) 0) < ((*result) ? (*result)->Sup.len : 0));
if (!(T57_)) goto LA58_;
T57_ = !((((NU8)((*result)->data[(NI)(((*result) ? (*result)->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47)) || ((NU8)((*result)->data[(NI)(((*result) ? (*result)->Sup.len : 0) - ((NI) 1))])) == ((NU8)(47))));
LA58_: ;
if (!T57_) goto LA59_;
unsureAsgnRef((void**) (&(*result)), addChar((*result), dirSep));
}
LA59_: ;
T61_ = NIM_NIL;
T61_ = substr__system_7755(x, b.Field0, b.Field1);
unsureAsgnRef((void**) (&(*result)), resizeString((*result), (T61_ ? T61_->Sup.len : 0) + 0));
appendString((*result), T61_);
(*state) += ((NI) 2);
}
goto LA12_;
LA53_: ;
LA12_: ;
} LA10: ;
}
{
NIM_BOOL T64_;
T64_ = (NIM_BOOL)0;
T64_ = (((*result) ? (*result)->Sup.len : 0) == 0);
if (!(T64_)) goto LA65_;
T64_ = !(((x ? x->Sup.len : 0) == 0));
LA65_: ;
if (!T64_) goto LA66_;
unsureAsgnRef((void**) (&(*result)), copyString(((NimStringDesc*) &TM__DfU0iuayCGwHDN1Exp9cbKg_2)));
}
LA66_: ;
}
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, normalizePath__pureZpathnorm_127)(NimStringDesc* path, NIM_CHAR dirSep) {
NimStringDesc* result;
NI state;
result = NIM_NIL;
result = rawNewString(((NI) ((path ? path->Sup.len : 0))));
state = ((NI) 0);
addNormalizePath__pureZpathnorm_71(path, (&result), (&state), dirSep);
return result;
}
|