Subversion Repositories SvarDOS

Rev

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

Rev 1822 Rev 1823
Line 253... Line 253...
253
 
253
 
254
 
254
 
255
/* builds the prompt string and displays it. buff is filled with a zero-terminated copy of the prompt. */
255
/* builds the prompt string and displays it. buff is filled with a zero-terminated copy of the prompt. */
256
static void build_and_display_prompt(char *buff, unsigned short envseg) {
256
static void build_and_display_prompt(char *buff, unsigned short envseg) {
257
  char *s = buff;
257
  char *s = buff;
-
 
258
 
258
  /* locate the prompt variable or use the default pattern */
259
  /* locate the prompt variable or use the default pattern */
259
  const char far *fmt = env_lookup_val(envseg, "PROMPT");
260
  const char far *fmt = env_lookup_val(envseg, "PROMPT");
260
  if ((fmt == NULL) || (*fmt == 0)) fmt = "$p$g"; /* fallback to default if empty */
261
  if ((fmt == NULL) || (*fmt == 0)) fmt = "$p$g"; /* fallback to default if empty */
-
 
262
 
261
  /* build the prompt string based on pattern */
263
  /* build the prompt string based on pattern */
262
  for (; *fmt != 0; fmt++) {
264
  for (; *fmt != 0; fmt++) {
263
    if (*fmt != '$') {
265
    if (*fmt != '$') {
264
      *s = *fmt;
266
      *s = *fmt;
265
      s++;
267
      s++;
Line 277... Line 279...
277
        *s = '$';
279
        *s = '$';
278
        s++;
280
        s++;
279
        break;
281
        break;
280
      case 'T':  /* $t = current time */
282
      case 'T':  /* $t = current time */
281
      case 't':
283
      case 't':
-
 
284
      {
-
 
285
        struct nls_patterns nls;
-
 
286
        unsigned char h, m, sec;
-
 
287
        if (nls_getpatterns(&nls) != 0) {
282
        s += sprintf(s, "00:00"); /* TODO */
288
          s += sprintf(s, "ERR");
-
 
289
        } else {
-
 
290
          dos_get_time(&h, &m, &sec);
-
 
291
          s += nls_format_time(s, h, m, sec, &nls);
-
 
292
        }
283
        break;
293
        break;
-
 
294
      }
284
      case 'D':  /* $D = current date */
295
      case 'D':  /* $D = current date */
285
      case 'd':
296
      case 'd':
-
 
297
      {
-
 
298
        struct nls_patterns nls;
-
 
299
        unsigned short y;
-
 
300
        unsigned char m, d;
-
 
301
        if (nls_getpatterns(&nls) != 0) {
286
        s += sprintf(s, "1985-07-29"); /* TODO */
302
          s += sprintf(s, "ERR");
-
 
303
        } else {
-
 
304
          dos_get_date(&y, &m, &d);
-
 
305
          s += nls_format_date(s, y, m, d, &nls);
-
 
306
        }
287
        break;
307
        break;
-
 
308
      }
288
      case 'P':  /* $P = current drive and path */
309
      case 'P':  /* $P = current drive and path */
289
      case 'p':
310
      case 'p':
290
        *s = _dosgetcurdrive() + 'A';
311
        *s = _dosgetcurdrive() + 'A';
291
        s++;
312
        s++;
292
        *s = ':';
313
        *s = ':';