Changeset 5145235 for util.c


Ignore:
Timestamp:
Sep 15, 2002, 4:45:38 PM (18 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
425c013
Parents:
61e79a9
Message:
Fix memory problem in setting default tty.
Removed some commented material from configure.in and owl.c
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r61e79a9 r5145235  
    22#include <stdlib.h>
    33#include <string.h>
     4#include <unistd.h>
    45#include <malloc.h>
    56#include <ctype.h>
     
    496497char *owl_util_get_default_tty() {
    497498  /* call must free the return */
    498   char *out;
     499  char *out, *tmp;
    499500
    500501  if (getenv("DISPLAY")) {
    501502    out=owl_strdup(getenv("DISPLAY"));
    502   } else if (ttyname(fileno(stdout))) {
    503     out=strdup(ttyname(fileno(stdout)));
     503  } else if ((tmp=ttyname(fileno(stdout)))!=NULL) {
     504    out=owl_strdup(tmp);
    504505    if (!strncmp(out, "/dev/", 5)) {
    505506      owl_free(out);
    506       out=strdup(ttyname(fileno(stdout)+5));
     507      out=owl_strdup(tmp+5);
    507508    }
    508509  } else {
    509     out=strdup("unknown");
     510    out=owl_strdup("unknown");
    510511  }
    511512  return(out);
Note: See TracChangeset for help on using the changeset viewer.