jot.c (afe53a495004970badeddefc4ea3f97ae0f84927) | jot.c (d737ec1ad49e1d8c904cfdfd63edd46e22e00776) |
---|---|
1/*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 170 unchanged lines hidden (view full) --- 179 default: 180 errx(1, "too many arguments. What do you mean by %s?", 181 argv[4]); 182 } 183 getformat(); 184 while (mask) /* 4 bit mask has 1's where last 4 args were given */ 185 switch (mask) { /* fill in the 0's by default or computation */ 186 case HAVE_STEP: | 1/*- 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 170 unchanged lines hidden (view full) --- 179 default: 180 errx(1, "too many arguments. What do you mean by %s?", 181 argv[4]); 182 } 183 getformat(); 184 while (mask) /* 4 bit mask has 1's where last 4 args were given */ 185 switch (mask) { /* fill in the 0's by default or computation */ 186 case HAVE_STEP: |
187 reps = REPS_DEF; 188 mask = HAVE_REPS | HAVE_STEP; 189 break; | |
190 case HAVE_ENDER: | 187 case HAVE_ENDER: |
191 reps = REPS_DEF; 192 mask = HAVE_REPS | HAVE_ENDER; 193 break; | |
194 case HAVE_ENDER | HAVE_STEP: | 188 case HAVE_ENDER | HAVE_STEP: |
195 reps = REPS_DEF; 196 mask = HAVE_REPS | HAVE_ENDER | HAVE_STEP; 197 break; | |
198 case HAVE_BEGIN: | 189 case HAVE_BEGIN: |
199 reps = REPS_DEF; 200 mask = HAVE_REPS | HAVE_BEGIN; 201 break; | |
202 case HAVE_BEGIN | HAVE_STEP: | 190 case HAVE_BEGIN | HAVE_STEP: |
203 reps = REPS_DEF; 204 mask = HAVE_REPS | HAVE_BEGIN | HAVE_STEP; 205 break; | |
206 case HAVE_BEGIN | HAVE_ENDER: 207 reps = REPS_DEF; | 191 case HAVE_BEGIN | HAVE_ENDER: 192 reps = REPS_DEF; |
208 mask = HAVE_REPS | HAVE_BEGIN | HAVE_ENDER; | 193 mask |= HAVE_REPS; |
209 break; 210 case HAVE_BEGIN | HAVE_ENDER | HAVE_STEP: | 194 break; 195 case HAVE_BEGIN | HAVE_ENDER | HAVE_STEP: |
211 if (randomize) { | 196 if (randomize) |
212 reps = REPS_DEF; | 197 reps = REPS_DEF; |
213 mask = 0; 214 break; 215 } 216 if (s == 0.0) { | 198 else if (s == 0.0) |
217 reps = 0; | 199 reps = 0; |
218 mask = 0; 219 break; 220 } 221 reps = (ender - begin + s) / s; | 200 else 201 reps = (ender - begin + s) / s; |
222 if (reps <= 0) 223 errx(1, "impossible stepsize"); 224 mask = 0; 225 break; 226 case HAVE_REPS: | 202 if (reps <= 0) 203 errx(1, "impossible stepsize"); 204 mask = 0; 205 break; 206 case HAVE_REPS: |
227 begin = BEGIN_DEF; 228 mask = HAVE_REPS | HAVE_BEGIN; 229 break; | |
230 case HAVE_REPS | HAVE_STEP: 231 begin = BEGIN_DEF; | 207 case HAVE_REPS | HAVE_STEP: 208 begin = BEGIN_DEF; |
232 mask = HAVE_REPS | HAVE_BEGIN | HAVE_STEP; | 209 mask |= HAVE_BEGIN; |
233 break; 234 case HAVE_REPS | HAVE_ENDER: 235 s = (randomize ? time(NULL) : STEP_DEF); 236 mask = HAVE_REPS | HAVE_ENDER | HAVE_STEP; 237 break; 238 case HAVE_REPS | HAVE_ENDER | HAVE_STEP: 239 if (randomize) 240 begin = BEGIN_DEF; --- 219 unchanged lines hidden --- | 210 break; 211 case HAVE_REPS | HAVE_ENDER: 212 s = (randomize ? time(NULL) : STEP_DEF); 213 mask = HAVE_REPS | HAVE_ENDER | HAVE_STEP; 214 break; 215 case HAVE_REPS | HAVE_ENDER | HAVE_STEP: 216 if (randomize) 217 begin = BEGIN_DEF; --- 219 unchanged lines hidden --- |