[7ee2b42] | 1 | /* extend.c |
---|
[d1b1380] | 2 | * Produce an extended elevation |
---|
[a412bc9] | 3 | * Copyright (C) 1995-2002,2005,2010,2011,2013,2014,2016,2017 Olly Betts |
---|
[d92d282] | 4 | * Copyright (C) 2004,2005 John Pybus |
---|
[846746e] | 5 | * |
---|
[89231c4] | 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
[846746e] | 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[89231c4] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | * GNU General Public License for more details. |
---|
[846746e] | 15 | * |
---|
[89231c4] | 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
[ecbc6c18] | 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
[d1b1380] | 19 | */ |
---|
| 20 | |
---|
[a420b49] | 21 | #ifdef HAVE_CONFIG_H |
---|
| 22 | # include <config.h> |
---|
| 23 | #endif |
---|
[d1b1380] | 24 | |
---|
[e55ee28] | 25 | #include <float.h> |
---|
[d1b1380] | 26 | #include <stdio.h> |
---|
| 27 | #include <stdlib.h> |
---|
| 28 | #include <string.h> |
---|
| 29 | |
---|
[acc20b1] | 30 | #include "cmdline.h" |
---|
[693388e] | 31 | #include "debug.h" |
---|
[d1b1380] | 32 | #include "filelist.h" |
---|
[693388e] | 33 | #include "filename.h" |
---|
| 34 | #include "hash.h" |
---|
[a405bc1] | 35 | #include "img_hosted.h" |
---|
[693388e] | 36 | #include "message.h" |
---|
| 37 | #include "useful.h" |
---|
[d1b1380] | 38 | |
---|
[693388e] | 39 | /* To save memory we should probably use the prefix hash for the prefix on |
---|
| 40 | * point labels (FIXME) */ |
---|
[ea1c342] | 41 | |
---|
| 42 | typedef struct stn { |
---|
| 43 | const char *label; |
---|
| 44 | int flags; |
---|
[ee11c6a7] | 45 | const struct stn *next; |
---|
[ea1c342] | 46 | } stn; |
---|
| 47 | |
---|
[ae6d92e] | 48 | typedef struct splay { |
---|
| 49 | struct POINT *pt; |
---|
| 50 | struct splay *next; |
---|
| 51 | } splay; |
---|
| 52 | |
---|
[d1b1380] | 53 | typedef struct POINT { |
---|
[0ed0e16] | 54 | img_point p; |
---|
[9f841e3] | 55 | double X; |
---|
[ea1c342] | 56 | const stn *stns; |
---|
[647407d] | 57 | unsigned int order; |
---|
[d92d282] | 58 | char dir; |
---|
| 59 | char fDone; |
---|
| 60 | char fBroken; |
---|
[ae6d92e] | 61 | splay *splays; |
---|
[d1b1380] | 62 | struct POINT *next; |
---|
| 63 | } point; |
---|
| 64 | |
---|
| 65 | typedef struct LEG { |
---|
| 66 | point *fr, *to; |
---|
[693388e] | 67 | const char *prefix; |
---|
[d92d282] | 68 | char dir; |
---|
| 69 | char fDone; |
---|
| 70 | char broken; |
---|
[95c3272] | 71 | int flags; |
---|
| 72 | struct LEG *next; |
---|
[d1b1380] | 73 | } leg; |
---|
| 74 | |
---|
[d92d282] | 75 | /* Values for leg.broken: */ |
---|
| 76 | #define BREAK_FR 0x01 |
---|
| 77 | #define BREAK_TO 0x02 |
---|
[d1b1380] | 78 | |
---|
[d92d282] | 79 | /* Values for point.dir and leg.dir: */ |
---|
| 80 | #define ELEFT 0x01 |
---|
| 81 | #define ERIGHT 0x02 |
---|
| 82 | #define ESWAP 0x04 |
---|
| 83 | |
---|
[ae6d92e] | 84 | static point headpoint = {{0, 0, 0}, 0, NULL, 0, 0, 0, 0, NULL, NULL}; |
---|
[d92d282] | 85 | |
---|
| 86 | static leg headleg = {NULL, NULL, NULL, 0, 0, 0, 0, NULL}; |
---|
[d1b1380] | 87 | |
---|
[31b7105] | 88 | static img *pimg_out; |
---|
[d1b1380] | 89 | |
---|
[c50cbcf] | 90 | static int show_breaks = 0; |
---|
| 91 | |
---|
[e67cb60] | 92 | static void do_stn(point *, double, const char *, int, int, double, double); |
---|
[d1b1380] | 93 | |
---|
[693388e] | 94 | typedef struct pfx { |
---|
| 95 | const char *label; |
---|
| 96 | struct pfx *next; |
---|
| 97 | } pfx; |
---|
| 98 | |
---|
| 99 | static pfx **htab; |
---|
| 100 | |
---|
[63dc4eb] | 101 | #define HTAB_SIZE 0x2000 |
---|
| 102 | |
---|
[693388e] | 103 | static const char * |
---|
| 104 | find_prefix(const char *prefix) |
---|
| 105 | { |
---|
| 106 | pfx *p; |
---|
| 107 | int hash; |
---|
| 108 | |
---|
[4c07c51] | 109 | SVX_ASSERT(prefix); |
---|
[421b7d2] | 110 | |
---|
[63dc4eb] | 111 | hash = hash_string(prefix) & (HTAB_SIZE - 1); |
---|
[693388e] | 112 | for (p = htab[hash]; p; p = p->next) { |
---|
| 113 | if (strcmp(prefix, p->label) == 0) return p->label; |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | p = osnew(pfx); |
---|
| 117 | p->label = osstrdup(prefix); |
---|
| 118 | p->next = htab[hash]; |
---|
| 119 | htab[hash] = p; |
---|
| 120 | |
---|
| 121 | return p->label; |
---|
| 122 | } |
---|
| 123 | |
---|
[a420b49] | 124 | static point * |
---|
[0ed0e16] | 125 | find_point(const img_point *pt) |
---|
[a420b49] | 126 | { |
---|
[d1b1380] | 127 | point *p; |
---|
[647407d] | 128 | for (p = headpoint.next; p != NULL; p = p->next) { |
---|
[0ed0e16] | 129 | if (pt->x == p->p.x && pt->y == p->p.y && pt->z == p->p.z) { |
---|
[647407d] | 130 | return p; |
---|
| 131 | } |
---|
| 132 | } |
---|
[a420b49] | 133 | |
---|
| 134 | p = osmalloc(ossizeof(point)); |
---|
[0ed0e16] | 135 | p->p = *pt; |
---|
[9f841e3] | 136 | p->X = HUGE_VAL; |
---|
[ea1c342] | 137 | p->stns = NULL; |
---|
[7ee2b42] | 138 | p->order = 0; |
---|
[d92d282] | 139 | p->dir = 0; |
---|
| 140 | p->fDone = 0; |
---|
[8add4c9] | 141 | p->fBroken = 0; |
---|
[ae6d92e] | 142 | p->splays = NULL; |
---|
[a420b49] | 143 | p->next = headpoint.next; |
---|
| 144 | headpoint.next = p; |
---|
[d1b1380] | 145 | return p; |
---|
| 146 | } |
---|
| 147 | |
---|
[a420b49] | 148 | static void |
---|
[693388e] | 149 | add_leg(point *fr, point *to, const char *prefix, int flags) |
---|
[a420b49] | 150 | { |
---|
[95c3272] | 151 | leg *l; |
---|
[7ee2b42] | 152 | fr->order++; |
---|
| 153 | to->order++; |
---|
[95c3272] | 154 | l = osmalloc(ossizeof(leg)); |
---|
| 155 | l->fr = fr; |
---|
| 156 | l->to = to; |
---|
[693388e] | 157 | if (prefix) |
---|
| 158 | l->prefix = find_prefix(prefix); |
---|
| 159 | else |
---|
| 160 | l->prefix = NULL; |
---|
[95c3272] | 161 | l->next = headleg.next; |
---|
[d92d282] | 162 | l->dir = 0; |
---|
[95c3272] | 163 | l->fDone = 0; |
---|
[8add4c9] | 164 | l->broken = 0; |
---|
[95c3272] | 165 | l->flags = flags; |
---|
| 166 | headleg.next = l; |
---|
[d1b1380] | 167 | } |
---|
| 168 | |
---|
[a420b49] | 169 | static void |
---|
[95c3272] | 170 | add_label(point *p, const char *label, int flags) |
---|
[a420b49] | 171 | { |
---|
[ea1c342] | 172 | stn *s = osnew(stn); |
---|
| 173 | s->label = osstrdup(label); |
---|
| 174 | s->flags = flags; |
---|
| 175 | s->next = p->stns; |
---|
| 176 | p->stns = s; |
---|
[d1b1380] | 177 | } |
---|
| 178 | |
---|
[d92d282] | 179 | /* Read in config file */ |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | /* lifted from img.c Should be put somewhere common? JPNP*/ |
---|
| 183 | static char * |
---|
| 184 | getline_alloc(FILE *fh, size_t ilen) |
---|
| 185 | { |
---|
| 186 | int ch; |
---|
| 187 | size_t i = 0; |
---|
| 188 | size_t len = ilen; |
---|
| 189 | char *buf = xosmalloc(len); |
---|
| 190 | if (!buf) return NULL; |
---|
| 191 | |
---|
[e02a6a6] | 192 | ch = GETC(fh); |
---|
[d92d282] | 193 | while (ch != '\n' && ch != '\r' && ch != EOF) { |
---|
| 194 | buf[i++] = ch; |
---|
| 195 | if (i == len - 1) { |
---|
| 196 | char *p; |
---|
| 197 | len += len; |
---|
| 198 | p = xosrealloc(buf, len); |
---|
| 199 | if (!p) { |
---|
| 200 | osfree(buf); |
---|
| 201 | return NULL; |
---|
| 202 | } |
---|
| 203 | buf = p; |
---|
| 204 | } |
---|
[e02a6a6] | 205 | ch = GETC(fh); |
---|
[d92d282] | 206 | } |
---|
| 207 | if (ch == '\n' || ch == '\r') { |
---|
| 208 | int otherone = ch ^ ('\n' ^ '\r'); |
---|
[e02a6a6] | 209 | ch = GETC(fh); |
---|
[d92d282] | 210 | /* if it's not the other eol character, put it back */ |
---|
| 211 | if (ch != otherone) ungetc(ch, fh); |
---|
| 212 | } |
---|
| 213 | buf[i++] = '\0'; |
---|
| 214 | return buf; |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | static int lineno = 0; |
---|
| 218 | static point *start = NULL; |
---|
| 219 | |
---|
| 220 | static char* |
---|
| 221 | delimword(char *ln, char** lr) |
---|
| 222 | { |
---|
| 223 | char *le; |
---|
| 224 | |
---|
| 225 | while (*ln == ' ' || *ln == '\t' || *ln == '\n' || *ln == '\r') |
---|
| 226 | ln++; |
---|
| 227 | |
---|
| 228 | le = ln; |
---|
| 229 | while (*le != ' ' && *le != '\t' && *le != '\n' && *le != '\r' && *le != ';' && *le != '\0') |
---|
| 230 | le++; |
---|
| 231 | |
---|
| 232 | if (*le == '\0' || *le == ';') { |
---|
| 233 | *lr = le; |
---|
| 234 | } else { |
---|
| 235 | *lr = le + 1; |
---|
| 236 | } |
---|
[6e4a123] | 237 | |
---|
[d92d282] | 238 | *le = '\0'; |
---|
| 239 | return ln; |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | static void |
---|
[7926772] | 243 | parseconfigline(const char *fnm, char *ln) |
---|
[d92d282] | 244 | { |
---|
| 245 | point *p; |
---|
| 246 | const stn *s; |
---|
| 247 | const stn *t; |
---|
| 248 | leg *l; |
---|
| 249 | char *lc = NULL; |
---|
| 250 | |
---|
| 251 | ln = delimword(ln, &lc); |
---|
| 252 | |
---|
| 253 | if (*ln == '\0') return; |
---|
| 254 | |
---|
| 255 | if (strcmp(ln, "*start")==0) { |
---|
| 256 | ln = delimword(lc, &lc); |
---|
[7926772] | 257 | if (*ln == 0) |
---|
[0b8c321] | 258 | /* TRANSLATORS: Here "station" is a survey station, not a train station. */ |
---|
[7926772] | 259 | fatalerror_in_file(fnm, lineno, /*Expecting station name*/28); |
---|
[d92d282] | 260 | for (p = headpoint.next; p != NULL; p = p->next) { |
---|
| 261 | for (s = p->stns; s; s = s->next) { |
---|
| 262 | if (strcmp(s->label, ln)==0) { |
---|
| 263 | start = p; |
---|
[736f7df] | 264 | /* TRANSLATORS: for extend: "extend" is starting to produce an extended elevation from station %s */ |
---|
[7926772] | 265 | printf(msg(/*Starting from station %s*/512),ln); |
---|
[d92d282] | 266 | putnl(); |
---|
| 267 | goto loopend; |
---|
| 268 | } |
---|
| 269 | } |
---|
| 270 | } |
---|
[736f7df] | 271 | /* TRANSLATORS: for extend: the user specified breaking a loop or |
---|
| 272 | * changing extend direction at this station, but we didn’t find it in |
---|
| 273 | * the 3d file */ |
---|
[7926772] | 274 | warning_in_file(fnm, lineno, /*Failed to find station %s*/510, ln); |
---|
[d92d282] | 275 | } else if (strcmp(ln, "*eleft")==0) { |
---|
| 276 | char *ll = delimword(lc, &lc); |
---|
[7926772] | 277 | if (*ll == 0) |
---|
| 278 | fatalerror_in_file(fnm, lineno, /*Expecting station name*/28); |
---|
[d92d282] | 279 | ln = delimword(lc, &lc); |
---|
[deb536fb] | 280 | if (*ln == 0) { |
---|
| 281 | /* One argument - look for station to switch at. */ |
---|
[d92d282] | 282 | for (p = headpoint.next; p != NULL; p = p->next) { |
---|
| 283 | for (s = p->stns; s; s = s->next) { |
---|
| 284 | if (strcmp(s->label, ll)==0) { |
---|
[736f7df] | 285 | /* TRANSLATORS: for extend: */ |
---|
[7926772] | 286 | printf(msg(/*Extending to the left from station %s*/513), ll); |
---|
[d92d282] | 287 | putnl(); |
---|
| 288 | p->dir = ELEFT; |
---|
| 289 | goto loopend; |
---|
| 290 | } |
---|
| 291 | } |
---|
| 292 | } |
---|
[7926772] | 293 | warning_in_file(fnm, lineno, /*Failed to find station %s*/510, ll); |
---|
[deb536fb] | 294 | } else { |
---|
| 295 | /* Two arguments - look for a specified leg. */ |
---|
[d92d282] | 296 | for (l = headleg.next; l; l=l->next) { |
---|
| 297 | point * fr = l->fr; |
---|
| 298 | point * to = l->to; |
---|
| 299 | if (fr && to) { |
---|
| 300 | for (s=fr->stns; s; s=s->next) { |
---|
| 301 | int b = 0; |
---|
| 302 | if (strcmp(s->label,ll)==0 || (strcmp(s->label, ln)==0 && (b = 1)) ) { |
---|
| 303 | char * lr = (b ? ll : ln); |
---|
| 304 | for (t=to->stns; t; t=t->next) { |
---|
| 305 | if (strcmp(t->label,lr)==0) { |
---|
[736f7df] | 306 | /* TRANSLATORS: for extend: */ |
---|
[ee7511a] | 307 | printf(msg(/*Extending to the left from leg %s → %s*/515), s->label, t->label); |
---|
[d92d282] | 308 | putnl(); |
---|
| 309 | l->dir = ELEFT; |
---|
| 310 | goto loopend; |
---|
| 311 | } |
---|
| 312 | } |
---|
| 313 | } |
---|
| 314 | } |
---|
| 315 | } |
---|
| 316 | } |
---|
[736f7df] | 317 | /* TRANSLATORS: for extend: the user specified breaking a loop or |
---|
| 318 | * changing extend direction at this leg, but we didn’t find it in the |
---|
| 319 | * 3d file */ |
---|
[ee7511a] | 320 | warning_in_file(fnm, lineno, /*Failed to find leg %s → %s*/511, ll, ln); |
---|
[d92d282] | 321 | } |
---|
| 322 | } else if (strcmp(ln, "*eright")==0) { |
---|
| 323 | char *ll = delimword(lc, &lc); |
---|
[7926772] | 324 | if (*ll == 0) |
---|
| 325 | fatalerror_in_file(fnm, lineno, /*Expecting station name*/28); |
---|
[d92d282] | 326 | ln = delimword(lc, &lc); |
---|
[deb536fb] | 327 | if (*ln == 0) { |
---|
| 328 | /* One argument - look for station to switch at. */ |
---|
[d92d282] | 329 | for (p = headpoint.next; p != NULL; p = p->next) { |
---|
| 330 | for (s = p->stns; s; s = s->next) { |
---|
| 331 | if (strcmp(s->label, ll)==0) { |
---|
[736f7df] | 332 | /* TRANSLATORS: for extend: */ |
---|
[7926772] | 333 | printf(msg(/*Extending to the right from station %s*/514), ll); |
---|
[d92d282] | 334 | putnl(); |
---|
| 335 | p->dir = ERIGHT; |
---|
| 336 | goto loopend; |
---|
| 337 | } |
---|
| 338 | } |
---|
| 339 | } |
---|
[7926772] | 340 | warning_in_file(fnm, lineno, /*Failed to find station %s*/510, ll); |
---|
[deb536fb] | 341 | } else { |
---|
| 342 | /* Two arguments - look for a specified leg. */ |
---|
[d92d282] | 343 | for (l = headleg.next; l; l=l->next) { |
---|
| 344 | point * fr = l->fr; |
---|
| 345 | point * to = l->to; |
---|
| 346 | if (fr && to) { |
---|
| 347 | for (s=fr->stns; s; s=s->next) { |
---|
| 348 | int b = 0; |
---|
| 349 | if (strcmp(s->label,ll)==0 || (strcmp(s->label, ln)==0 && (b = 1)) ) { |
---|
| 350 | char * lr = (b ? ll : ln); |
---|
| 351 | for (t=to->stns; t; t=t->next) { |
---|
| 352 | if (strcmp(t->label,lr)==0) { |
---|
[736f7df] | 353 | /* TRANSLATORS: for extend: */ |
---|
[ee7511a] | 354 | printf(msg(/*Extending to the right from leg %s → %s*/516), s->label, t->label); |
---|
[7926772] | 355 | putnl(); |
---|
[d92d282] | 356 | l->dir=ERIGHT; |
---|
| 357 | goto loopend; |
---|
| 358 | } |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | } |
---|
[ee7511a] | 364 | warning_in_file(fnm, lineno, /*Failed to find leg %s → %s*/511, ll, ln); |
---|
[d92d282] | 365 | } |
---|
| 366 | } else if (strcmp(ln, "*eswap")==0) { |
---|
| 367 | char *ll = delimword(lc, &lc); |
---|
[7926772] | 368 | if (*ll == 0) |
---|
| 369 | fatalerror_in_file(fnm, lineno, /*Expecting station name*/28); |
---|
[d92d282] | 370 | ln = delimword(lc, &lc); |
---|
[deb536fb] | 371 | if (*ln == 0) { |
---|
| 372 | /* One argument - look for station to switch at. */ |
---|
[d92d282] | 373 | for (p = headpoint.next; p != NULL; p = p->next) { |
---|
| 374 | for (s = p->stns; s; s = s->next) { |
---|
| 375 | if (strcmp(s->label, ll)==0) { |
---|
[736f7df] | 376 | /* TRANSLATORS: for extend: */ |
---|
[7926772] | 377 | printf(msg(/*Swapping extend direction from station %s*/519),ll); |
---|
[d92d282] | 378 | putnl(); |
---|
| 379 | p->dir = ESWAP; |
---|
| 380 | goto loopend; |
---|
| 381 | } |
---|
| 382 | } |
---|
| 383 | } |
---|
[7926772] | 384 | warning_in_file(fnm, lineno, /*Failed to find station %s*/510, ll); |
---|
[deb536fb] | 385 | } else { |
---|
| 386 | /* Two arguments - look for a specified leg. */ |
---|
[d92d282] | 387 | for (l = headleg.next; l; l=l->next) { |
---|
| 388 | point * fr = l->fr; |
---|
| 389 | point * to = l->to; |
---|
| 390 | if (fr && to) { |
---|
| 391 | for (s=fr->stns; s; s=s->next) { |
---|
| 392 | int b = 0; |
---|
| 393 | if (strcmp(s->label,ll)==0 || (strcmp(s->label, ln)==0 && (b = 1)) ) { |
---|
| 394 | char * lr = (b ? ll : ln); |
---|
| 395 | for (t=to->stns; t; t=t->next) { |
---|
| 396 | if (strcmp(t->label,lr)==0) { |
---|
[736f7df] | 397 | /* TRANSLATORS: for extend: */ |
---|
[ee7511a] | 398 | printf(msg(/*Swapping extend direction from leg %s → %s*/520), s->label, t->label); |
---|
[7926772] | 399 | putnl(); |
---|
[d92d282] | 400 | l->dir = ESWAP; |
---|
| 401 | goto loopend; |
---|
| 402 | } |
---|
| 403 | } |
---|
| 404 | } |
---|
| 405 | } |
---|
| 406 | } |
---|
| 407 | } |
---|
[ee7511a] | 408 | warning_in_file(fnm, lineno, /*Failed to find leg %s → %s*/511, ll, ln); |
---|
[d92d282] | 409 | } |
---|
| 410 | } else if (strcmp(ln, "*break")==0) { |
---|
| 411 | char *ll = delimword(lc, &lc); |
---|
[7926772] | 412 | if (*ll == 0) |
---|
| 413 | fatalerror_in_file(fnm, lineno, /*Expecting station name*/28); |
---|
[d92d282] | 414 | ln = delimword(lc, &lc); |
---|
[deb536fb] | 415 | if (*ln == 0) { |
---|
| 416 | /* One argument - look for specified station to break at. */ |
---|
[d92d282] | 417 | for (p = headpoint.next; p != NULL; p = p->next) { |
---|
| 418 | for (s = p->stns; s; s = s->next) { |
---|
| 419 | if (strcmp(s->label, ll)==0) { |
---|
[736f7df] | 420 | /* TRANSLATORS: for extend: */ |
---|
[7926772] | 421 | printf(msg(/*Breaking survey loop at station %s*/517), ll); |
---|
[d92d282] | 422 | putnl(); |
---|
| 423 | p->fBroken = 1; |
---|
| 424 | goto loopend; |
---|
| 425 | } |
---|
| 426 | } |
---|
| 427 | } |
---|
[7926772] | 428 | warning_in_file(fnm, lineno, /*Failed to find station %s*/510, ll); |
---|
[deb536fb] | 429 | } else { |
---|
| 430 | /* Two arguments - look for specified leg and disconnect it at the |
---|
| 431 | * first station. */ |
---|
[d92d282] | 432 | for (l = headleg.next; l; l=l->next) { |
---|
| 433 | point * fr = l->fr; |
---|
| 434 | point * to = l->to; |
---|
| 435 | if (fr && to) { |
---|
| 436 | for (s=fr->stns; s; s=s->next) { |
---|
| 437 | int b = 0; |
---|
| 438 | if (strcmp(s->label,ll)==0 || (strcmp(s->label, ln)==0 && (b = 1)) ) { |
---|
| 439 | char * lr = (b ? ll : ln); |
---|
| 440 | for (t=to->stns; t; t=t->next) { |
---|
| 441 | if (strcmp(t->label,lr)==0) { |
---|
[736f7df] | 442 | /* TRANSLATORS: for extend: */ |
---|
[ee7511a] | 443 | printf(msg(/*Breaking survey loop at leg %s → %s*/518), s->label, t->label); |
---|
[d92d282] | 444 | putnl(); |
---|
| 445 | l->broken = (b ? BREAK_TO : BREAK_FR); |
---|
| 446 | goto loopend; |
---|
| 447 | } |
---|
| 448 | } |
---|
| 449 | } |
---|
| 450 | } |
---|
| 451 | } |
---|
| 452 | } |
---|
[ee7511a] | 453 | warning_in_file(fnm, lineno, /*Failed to find leg %s → %s*/511, ll, ln); |
---|
[d92d282] | 454 | } |
---|
| 455 | } else { |
---|
[0804fbe] | 456 | fatalerror_in_file(fnm, lineno, /*Unknown command “%s”*/12, ln); |
---|
[d92d282] | 457 | } |
---|
| 458 | loopend: |
---|
| 459 | ln = delimword(lc, &lc); |
---|
| 460 | if (*ln != 0) { |
---|
[7926772] | 461 | fatalerror_in_file(fnm, lineno, /*End of line not blank*/15); |
---|
| 462 | /* FIXME: give ln as context? */ |
---|
[d92d282] | 463 | } |
---|
| 464 | } |
---|
| 465 | |
---|
[acc20b1] | 466 | static const struct option long_opts[] = { |
---|
| 467 | /* const char *name; int has_arg (0 no_argument, 1 required_*, 2 optional_*); int *flag; int val; */ |
---|
[76bbb7c9] | 468 | {"survey", required_argument, 0, 's'}, |
---|
[d92d282] | 469 | {"specfile", required_argument, 0, 'p'}, |
---|
[c50cbcf] | 470 | {"show-breaks", no_argument, 0, 'b' }, |
---|
[acc20b1] | 471 | {"help", no_argument, 0, HLP_HELP}, |
---|
| 472 | {"version", no_argument, 0, HLP_VERSION}, |
---|
| 473 | {0, 0, 0, 0} |
---|
| 474 | }; |
---|
| 475 | |
---|
[c50cbcf] | 476 | #define short_opts "s:p:b" |
---|
[acc20b1] | 477 | |
---|
| 478 | static struct help_msg help[] = { |
---|
| 479 | /* <-- */ |
---|
[45af761] | 480 | {HLP_ENCODELONG(0), /*only load the sub-survey with this prefix*/199, 0}, |
---|
[de934213] | 481 | /* TRANSLATORS: --help output for extend --specfile option */ |
---|
| 482 | {HLP_ENCODELONG(1), /*.espec file to control extending*/90, 0}, |
---|
[c50cbcf] | 483 | /* TRANSLATORS: --help output for extend --show-breaks option */ |
---|
| 484 | {HLP_ENCODELONG(2), /*show breaks with surface survey legs in output*/91, 0}, |
---|
[45af761] | 485 | {0, 0, 0} |
---|
[acc20b1] | 486 | }; |
---|
| 487 | |
---|
[47d8509] | 488 | static point * |
---|
| 489 | pick_start_stn(void) |
---|
| 490 | { |
---|
| 491 | point * best = NULL; |
---|
| 492 | double zMax = -DBL_MAX; |
---|
| 493 | point *p; |
---|
| 494 | |
---|
| 495 | /* Start at the highest entrance with some legs attached. */ |
---|
| 496 | for (p = headpoint.next; p != NULL; p = p->next) { |
---|
| 497 | if (p->order > 0 && p->p.z > zMax) { |
---|
| 498 | const stn *s; |
---|
| 499 | for (s = p->stns; s; s = s->next) { |
---|
| 500 | if (s->flags & img_SFLAG_ENTRANCE) { |
---|
| 501 | zMax = p->p.z; |
---|
| 502 | return p; |
---|
| 503 | } |
---|
| 504 | } |
---|
| 505 | } |
---|
| 506 | } |
---|
| 507 | if (best) return best; |
---|
| 508 | |
---|
| 509 | /* If no entrances with legs, start at the highest 1-node. */ |
---|
| 510 | for (p = headpoint.next; p != NULL; p = p->next) { |
---|
| 511 | if (p->order == 1 && p->p.z > zMax) { |
---|
| 512 | best = p; |
---|
| 513 | zMax = p->p.z; |
---|
| 514 | } |
---|
| 515 | } |
---|
| 516 | if (best) return best; |
---|
| 517 | |
---|
| 518 | /* of course we may have no 1-nodes... */ |
---|
| 519 | for (p = headpoint.next; p != NULL; p = p->next) { |
---|
| 520 | if (p->order != 0 && p->p.z > zMax) { |
---|
| 521 | best = p; |
---|
| 522 | zMax = p->p.z; |
---|
| 523 | } |
---|
| 524 | } |
---|
| 525 | if (best) return best; |
---|
| 526 | |
---|
| 527 | /* There are no legs - just pick the highest station... */ |
---|
| 528 | for (p = headpoint.next; p != NULL; p = p->next) { |
---|
| 529 | if (p->p.z > zMax) { |
---|
| 530 | best = p; |
---|
| 531 | zMax = p->p.z; |
---|
| 532 | } |
---|
| 533 | } |
---|
| 534 | return best; |
---|
| 535 | } |
---|
| 536 | |
---|
[a420b49] | 537 | int |
---|
| 538 | main(int argc, char **argv) |
---|
| 539 | { |
---|
[6f185e5] | 540 | const char *fnm_in, *fnm_out; |
---|
[a2ad284] | 541 | char *desc; |
---|
[0ed0e16] | 542 | img_point pt; |
---|
[d1b1380] | 543 | int result; |
---|
[647407d] | 544 | point *fr = NULL, *to; |
---|
[76bbb7c9] | 545 | const char *survey = NULL; |
---|
[d92d282] | 546 | const char *specfile = NULL; |
---|
[31b7105] | 547 | img *pimg; |
---|
[ae6d92e] | 548 | int xsections = 0, splays = 0; |
---|
[d1b1380] | 549 | |
---|
[bdfe97f] | 550 | msg_init(argv); |
---|
[d1b1380] | 551 | |
---|
[736f7df] | 552 | /* TRANSLATORS: Part of extend --help */ |
---|
[d8dbdff] | 553 | cmdline_set_syntax_message(/*INPUT_3D_FILE [OUTPUT_3D_FILE]*/267, 0, NULL); |
---|
[acc20b1] | 554 | cmdline_init(argc, argv, short_opts, long_opts, NULL, help, 1, 2); |
---|
[76bbb7c9] | 555 | while (1) { |
---|
| 556 | int opt = cmdline_getopt(); |
---|
| 557 | if (opt == EOF) break; |
---|
[cffe70f] | 558 | switch (opt) { |
---|
[c50cbcf] | 559 | case 'b': |
---|
| 560 | show_breaks = 1; |
---|
| 561 | break; |
---|
[cffe70f] | 562 | case 's': |
---|
| 563 | survey = optarg; |
---|
| 564 | break; |
---|
| 565 | case 'p': |
---|
| 566 | specfile = optarg; |
---|
| 567 | break; |
---|
| 568 | } |
---|
[acc20b1] | 569 | } |
---|
[6f185e5] | 570 | fnm_in = argv[optind++]; |
---|
[acc20b1] | 571 | if (argv[optind]) { |
---|
[6f185e5] | 572 | fnm_out = argv[optind]; |
---|
[acc20b1] | 573 | } else { |
---|
[6379f93] | 574 | char * base_in = base_from_fnm(fnm_in); |
---|
| 575 | char * base_out = osmalloc(strlen(base_in) + 8); |
---|
| 576 | strcpy(base_out, base_in); |
---|
| 577 | strcat(base_out, "_extend"); |
---|
| 578 | fnm_out = add_ext(base_out, EXT_SVX_3D); |
---|
| 579 | osfree(base_in); |
---|
| 580 | osfree(base_out); |
---|
[d1b1380] | 581 | } |
---|
| 582 | |
---|
| 583 | /* try to open image file, and check it has correct header */ |
---|
[a2ad284] | 584 | pimg = img_open_survey(fnm_in, survey); |
---|
[a405bc1] | 585 | if (pimg == NULL) fatalerror(img_error2msg(img_error()), fnm_in); |
---|
[d1b1380] | 586 | |
---|
| 587 | putnl(); |
---|
[ee7511a] | 588 | puts(msg(/*Reading in data - please wait…*/105)); |
---|
[d1b1380] | 589 | |
---|
[63dc4eb] | 590 | htab = osmalloc(ossizeof(pfx*) * HTAB_SIZE); |
---|
| 591 | { |
---|
| 592 | int i; |
---|
| 593 | for (i = 0; i < HTAB_SIZE; ++i) htab[i] = NULL; |
---|
| 594 | } |
---|
[421b7d2] | 595 | |
---|
[d1b1380] | 596 | do { |
---|
[23f7ea7] | 597 | result = img_read_item(pimg, &pt); |
---|
[d1b1380] | 598 | switch (result) { |
---|
[a420b49] | 599 | case img_MOVE: |
---|
[421b7d2] | 600 | fr = find_point(&pt); |
---|
| 601 | break; |
---|
[a420b49] | 602 | case img_LINE: |
---|
[421b7d2] | 603 | if (!fr) { |
---|
[76bbb7c9] | 604 | result = img_BAD; |
---|
| 605 | break; |
---|
[421b7d2] | 606 | } |
---|
| 607 | to = find_point(&pt); |
---|
[ae6d92e] | 608 | if (!(pimg->flags & img_FLAG_SURFACE)) { |
---|
| 609 | if (pimg->flags & img_FLAG_SPLAY) { |
---|
| 610 | ++splays; |
---|
| 611 | } else { |
---|
| 612 | add_leg(fr, to, pimg->label, pimg->flags); |
---|
| 613 | } |
---|
| 614 | } |
---|
[421b7d2] | 615 | fr = to; |
---|
| 616 | break; |
---|
[a420b49] | 617 | case img_LABEL: |
---|
[388ad50] | 618 | to = find_point(&pt); |
---|
| 619 | add_label(to, pimg->label, pimg->flags); |
---|
[421b7d2] | 620 | break; |
---|
[ed0f5b6] | 621 | case img_BAD: |
---|
[6f185e5] | 622 | (void)img_close(pimg); |
---|
[a405bc1] | 623 | fatalerror(img_error2msg(img_error()), fnm_in); |
---|
[31b7105] | 624 | break; |
---|
| 625 | case img_XSECT: |
---|
[a412bc9] | 626 | case img_XSECT_END: |
---|
| 627 | ++xsections; |
---|
[b49ac56] | 628 | break; |
---|
[d1b1380] | 629 | } |
---|
[ed0f5b6] | 630 | } while (result != img_STOP); |
---|
[d1b1380] | 631 | |
---|
[ae6d92e] | 632 | if (splays) { |
---|
| 633 | img_rewind(pimg); |
---|
| 634 | fr = NULL; |
---|
| 635 | do { |
---|
| 636 | result = img_read_item(pimg, &pt); |
---|
| 637 | switch (result) { |
---|
| 638 | case img_MOVE: |
---|
| 639 | fr = find_point(&pt); |
---|
| 640 | break; |
---|
| 641 | case img_LINE: |
---|
| 642 | if (!fr) { |
---|
| 643 | result = img_BAD; |
---|
| 644 | break; |
---|
| 645 | } |
---|
| 646 | to = find_point(&pt); |
---|
| 647 | if (!(pimg->flags & img_FLAG_SURFACE)) { |
---|
| 648 | if (pimg->flags & img_FLAG_SPLAY) { |
---|
| 649 | splay *sp = osmalloc(ossizeof(splay)); |
---|
| 650 | --splays; |
---|
| 651 | if (fr->order) { |
---|
| 652 | if (to->order == 0) { |
---|
| 653 | sp->pt = to; |
---|
| 654 | sp->next = fr->splays; |
---|
| 655 | fr->splays = sp; |
---|
| 656 | } else { |
---|
| 657 | printf("Splay without a dead end from %s to %s\n", fr->stns->label, to->stns->label); |
---|
| 658 | osfree(sp); |
---|
| 659 | } |
---|
| 660 | } else if (to->order) { |
---|
| 661 | sp->pt = fr; |
---|
| 662 | sp->next = to->splays; |
---|
| 663 | to->splays = sp; |
---|
| 664 | } else { |
---|
| 665 | printf("Isolated splay from %s to %s\n", fr->stns->label, to->stns->label); |
---|
| 666 | osfree(sp); |
---|
| 667 | } |
---|
| 668 | } |
---|
| 669 | } |
---|
| 670 | fr = to; |
---|
| 671 | break; |
---|
| 672 | } |
---|
| 673 | } while (splays && result != img_STOP); |
---|
| 674 | } |
---|
| 675 | |
---|
[0c50ce3] | 676 | desc = osstrdup(pimg->title); |
---|
[a2ad284] | 677 | |
---|
[d92d282] | 678 | if (specfile) { |
---|
| 679 | FILE *fs = NULL; |
---|
[7926772] | 680 | char *fnm_used; |
---|
[736f7df] | 681 | /* TRANSLATORS: for extend: */ |
---|
[0804fbe] | 682 | printf(msg(/*Applying specfile: “%s”*/521), specfile); |
---|
[d92d282] | 683 | putnl(); |
---|
[7926772] | 684 | fs = fopenWithPthAndExt("", specfile, NULL, "r", &fnm_used); |
---|
[ffee37e] | 685 | if (fs == NULL) fatalerror(/*Couldn’t open file “%s”*/24, specfile); |
---|
[d92d282] | 686 | while (!feof(fs)) { |
---|
[7926772] | 687 | char *lbuf = getline_alloc(fs, 32); |
---|
[d92d282] | 688 | lineno++; |
---|
[7926772] | 689 | if (!lbuf) |
---|
| 690 | fatalerror_in_file(fnm_used, lineno, /*Error reading file*/18); |
---|
| 691 | parseconfigline(fnm_used, lbuf); |
---|
[d92d282] | 692 | osfree(lbuf); |
---|
[647407d] | 693 | } |
---|
[7926772] | 694 | osfree(fnm_used); |
---|
[647407d] | 695 | } |
---|
[d92d282] | 696 | |
---|
[deb536fb] | 697 | if (start == NULL) { |
---|
[47d8509] | 698 | /* *start wasn't specified in specfile. */ |
---|
| 699 | start = pick_start_stn(); |
---|
| 700 | if (!start) fatalerror(/*No survey data*/43); |
---|
[647407d] | 701 | } |
---|
[d92d282] | 702 | |
---|
[736f7df] | 703 | /* TRANSLATORS: for extend: |
---|
| 704 | * Used to tell the user that a file is being written - %s is the filename |
---|
| 705 | */ |
---|
[ee7511a] | 706 | printf(msg(/*Writing %s…*/522), fnm_out); |
---|
[d92d282] | 707 | putnl(); |
---|
[0c50ce3] | 708 | pimg_out = img_open_write(fnm_out, desc, img_FFLAG_EXTENDED); |
---|
[d1b1380] | 709 | |
---|
[d92d282] | 710 | /* Only does single connected component currently. */ |
---|
[e67cb60] | 711 | do_stn(start, 0.0, NULL, ERIGHT, 0, 0.0, 0.0); |
---|
[31b7105] | 712 | |
---|
[a412bc9] | 713 | if (xsections) { |
---|
[31b7105] | 714 | img_rewind(pimg); |
---|
[2f1c0c0] | 715 | /* Read ahead on pimg before writing pimg_out so we find out if an |
---|
| 716 | * img_XSECT_END comes next. */ |
---|
| 717 | char * label = NULL; |
---|
| 718 | int flags = 0; |
---|
[31b7105] | 719 | do { |
---|
| 720 | result = img_read_item(pimg, &pt); |
---|
[a412bc9] | 721 | if (result != img_XSECT && result != img_XSECT_END) |
---|
| 722 | continue; |
---|
| 723 | --xsections; |
---|
| 724 | if (label) { |
---|
| 725 | if (result == img_XSECT_END) |
---|
| 726 | flags |= img_XFLAG_END; |
---|
| 727 | img_write_item(pimg_out, img_XSECT, flags, label, 0, 0, 0); |
---|
| 728 | osfree(label); |
---|
| 729 | label = NULL; |
---|
[2f1c0c0] | 730 | } |
---|
[31b7105] | 731 | if (result == img_XSECT) { |
---|
[2f1c0c0] | 732 | label = osstrdup(pimg->label); |
---|
| 733 | flags = pimg->flags; |
---|
| 734 | pimg_out->l = pimg->l; |
---|
| 735 | pimg_out->r = pimg->r; |
---|
| 736 | pimg_out->u = pimg->u; |
---|
[31b7105] | 737 | pimg_out->d = pimg->d; |
---|
| 738 | } |
---|
[a412bc9] | 739 | } while (xsections && result != img_STOP); |
---|
[31b7105] | 740 | } |
---|
[8add4c9] | 741 | |
---|
[31b7105] | 742 | (void)img_close(pimg); |
---|
| 743 | |
---|
| 744 | if (!img_close(pimg_out)) { |
---|
[6f185e5] | 745 | (void)remove(fnm_out); |
---|
[a405bc1] | 746 | fatalerror(img_error2msg(img_error()), fnm_out); |
---|
[6f185e5] | 747 | } |
---|
[cb3d1e2] | 748 | |
---|
[d1b1380] | 749 | return EXIT_SUCCESS; |
---|
| 750 | } |
---|
| 751 | |
---|
[d92d282] | 752 | static int adjust_direction(int dir, int by) { |
---|
| 753 | if (by == ESWAP) |
---|
| 754 | return dir ^ (ELEFT|ERIGHT); |
---|
| 755 | if (by) |
---|
| 756 | return by; |
---|
| 757 | return dir; |
---|
| 758 | } |
---|
| 759 | |
---|
[a420b49] | 760 | static void |
---|
[e67cb60] | 761 | do_splays(point *p, double X, int dir, double tdx, double tdy) |
---|
[ae6d92e] | 762 | { |
---|
| 763 | const splay *sp; |
---|
| 764 | double a; |
---|
| 765 | double C, S; |
---|
| 766 | |
---|
[e67cb60] | 767 | if (!p->splays) return; |
---|
[ae6d92e] | 768 | |
---|
[e67cb60] | 769 | if (tdx == 0 && tdy == 0) { |
---|
| 770 | /* Two adjacent plumbs, or a pair of legs that exactly cancel. */ |
---|
| 771 | return; |
---|
| 772 | } |
---|
| 773 | |
---|
| 774 | /* Bearing in radians. */ |
---|
| 775 | a = atan2(tdx, tdy); |
---|
[ae6d92e] | 776 | if (dir == ELEFT) { |
---|
[e67cb60] | 777 | a = -M_PI_2 - a; |
---|
[ae6d92e] | 778 | } else { |
---|
[e67cb60] | 779 | a = M_PI_2 - a; |
---|
[ae6d92e] | 780 | } |
---|
| 781 | C = cos(a); |
---|
| 782 | S = sin(a); |
---|
| 783 | for (sp = p->splays; sp; sp = sp->next) { |
---|
| 784 | double x = X; |
---|
| 785 | double z = p->p.z; |
---|
| 786 | img_write_item(pimg_out, img_MOVE, 0, NULL, x, 0, z); |
---|
| 787 | |
---|
| 788 | double dx = sp->pt->p.x - p->p.x; |
---|
| 789 | double dy = sp->pt->p.y - p->p.y; |
---|
| 790 | double dz = sp->pt->p.z - p->p.z; |
---|
| 791 | |
---|
| 792 | double tmp = dx * C + dy * S; |
---|
| 793 | dy = dy * C - dx * S; |
---|
| 794 | dx = tmp; |
---|
| 795 | |
---|
| 796 | img_write_item(pimg_out, img_LINE, img_FLAG_SPLAY, NULL, x + dx, dy, z + dz); |
---|
| 797 | } |
---|
| 798 | p->splays = NULL; |
---|
| 799 | } |
---|
| 800 | |
---|
| 801 | static void |
---|
[e67cb60] | 802 | do_stn(point *p, double X, const char *prefix, int dir, int labOnly, |
---|
| 803 | double odx, double ody) |
---|
[a420b49] | 804 | { |
---|
| 805 | leg *l, *lp; |
---|
[badeec8] | 806 | double dX; |
---|
[ee11c6a7] | 807 | const stn *s; |
---|
[d92d282] | 808 | int odir = dir; |
---|
[74506f1] | 809 | int try_all; |
---|
[ae6d92e] | 810 | int order = p->order; |
---|
| 811 | |
---|
[ea1c342] | 812 | for (s = p->stns; s; s = s->next) { |
---|
[31b7105] | 813 | img_write_item(pimg_out, img_LABEL, s->flags, s->label, X, 0, p->p.z); |
---|
[ea1c342] | 814 | } |
---|
[ae6d92e] | 815 | |
---|
[110957b] | 816 | if (show_breaks && p->X != HUGE_VAL && p->X != X) { |
---|
[9f841e3] | 817 | /* Draw "surface" leg between broken stations. */ |
---|
| 818 | img_write_item(pimg_out, img_MOVE, 0, NULL, p->X, 0, p->p.z); |
---|
| 819 | img_write_item(pimg_out, img_LINE, img_FLAG_SURFACE, NULL, X, 0, p->p.z); |
---|
| 820 | } |
---|
| 821 | p->X = X; |
---|
[d92d282] | 822 | if (labOnly || p->fBroken) { |
---|
| 823 | return; |
---|
| 824 | } |
---|
| 825 | |
---|
[ae6d92e] | 826 | |
---|
| 827 | if (order == 0) { |
---|
| 828 | /* We've reached a dead end. */ |
---|
[e67cb60] | 829 | do_splays(p, X, dir, odx, ody); |
---|
[ae6d92e] | 830 | return; |
---|
| 831 | } |
---|
| 832 | |
---|
[a16d11b] | 833 | /* It's better to follow legs along a survey, so make two passes and only |
---|
| 834 | * follow legs in the same survey for the first pass. |
---|
| 835 | */ |
---|
[74506f1] | 836 | for (try_all = 0; try_all != 2; ++try_all) { |
---|
[a16d11b] | 837 | lp = &headleg; |
---|
| 838 | for (l = lp->next; l; lp = l, l = lp->next) { |
---|
| 839 | dir = odir; |
---|
| 840 | if (l->fDone) { |
---|
| 841 | /* this case happens iff a recursive call causes the next leg to be |
---|
| 842 | * removed, leaving our next pointing to a leg which has been dealt |
---|
| 843 | * with... */ |
---|
| 844 | continue; |
---|
| 845 | } |
---|
| 846 | if (!try_all && l->prefix != prefix) { |
---|
| 847 | continue; |
---|
| 848 | } |
---|
[ea8d9a1] | 849 | int break_flag; |
---|
| 850 | point *p2; |
---|
[a16d11b] | 851 | if (l->to == p) { |
---|
[ea8d9a1] | 852 | break_flag = BREAK_TO; |
---|
| 853 | p2 = l->fr; |
---|
[a16d11b] | 854 | } else if (l->fr == p) { |
---|
[ea8d9a1] | 855 | break_flag = BREAK_FR; |
---|
| 856 | p2 = l->to; |
---|
| 857 | } else { |
---|
| 858 | continue; |
---|
| 859 | } |
---|
| 860 | if (l->broken & break_flag) continue; |
---|
| 861 | lp->next = l->next; |
---|
| 862 | /* adjust direction of extension if necessary */ |
---|
| 863 | dir = adjust_direction(dir, p->dir); |
---|
| 864 | dir = adjust_direction(dir, l->dir); |
---|
| 865 | |
---|
| 866 | double dx = p2->p.x - p->p.x; |
---|
| 867 | double dy = p2->p.y - p->p.y; |
---|
| 868 | dX = hypot(dx, dy); |
---|
| 869 | double X2 = X; |
---|
| 870 | if (dir == ELEFT) { |
---|
[ae6d92e] | 871 | X2 -= dX; |
---|
[ea8d9a1] | 872 | } else { |
---|
[ae6d92e] | 873 | X2 += dX; |
---|
[a16d11b] | 874 | } |
---|
[ea8d9a1] | 875 | |
---|
[5b1703f] | 876 | if (p->splays) { |
---|
[e67cb60] | 877 | do_splays(p, X, dir, odx + dx, ody + dy); |
---|
[5b1703f] | 878 | } |
---|
[ae6d92e] | 879 | |
---|
[ea8d9a1] | 880 | img_write_item(pimg_out, img_MOVE, 0, NULL, X, 0, p->p.z); |
---|
| 881 | img_write_item(pimg_out, img_LINE, l->flags, l->prefix, |
---|
| 882 | X2, 0, p2->p.z); |
---|
| 883 | |
---|
[e67cb60] | 884 | /* We arrive at p2 via a leg, so that's one down right away. */ |
---|
| 885 | --p2->order; |
---|
| 886 | |
---|
[ea8d9a1] | 887 | l->fDone = 1; |
---|
| 888 | /* l->broken doesn't have break_flag set as we checked that above. */ |
---|
[e67cb60] | 889 | do_stn(p2, X2, l->prefix, dir, l->broken, dx, dy); |
---|
[ea8d9a1] | 890 | l = lp; |
---|
[ae6d92e] | 891 | if (--order == 0) return; |
---|
[d1b1380] | 892 | } |
---|
| 893 | } |
---|
| 894 | } |
---|