rem: } if(!option_source){   format_node *fn;
add: if(thread_flags & TF_U_T){ fn = do_one_spec("spid", NULL); if(!fmt_add_after("PID", fn) && (thread_flags&TF_must_use)) return "-T with H/-m/m but no PID for SPID to follow"; } if(thread_flags & TF_U_L){ fn = do_one_spec("lwp", NULL); if(fmt_add_after("SID",  fn)) goto did_lwp; if(fmt_add_after("SESS", fn)) goto did_lwp; if(fmt_add_after("PGID", fn)) goto did_lwp; if(fmt_add_after("PGRP", fn)) goto did_lwp; if(fmt_add_after("PPID", fn)) goto did_lwp; if(fmt_add_after("PID",  fn)) goto did_lwp; if(thread_flags&TF_must_use) return "-L with H/-m/m but no PID/PGID/SID/SESS for NLWP to follow"; did_lwp: fn = do_one_spec("nlwp", NULL); fmt_add_after("%CPU",  fn); }
context: const char *process_sf_options(int localbroken){  sf_node *sf_walk;  int option_source;  /* true if user-defined */  if(personality & PER_BROKEN_o) localbroken = 1;  if(personality & PER_GOOD_o)   localbroken = 0;  broken = localbroken;  if(sf_list){    const char *err;    err = parse_O_option(sf_list);    if(err) return err;  }  if(format_list) printf("Bug: must reset the list first!\n");  /* merge formatting info of sf_list into format_list here */  sf_walk = sf_list;  while(sf_walk){    format_node *fmt_walk;    fmt_walk = sf_walk->f_cooked;    sf_walk->f_cooked = NULL;    while(fmt_walk){   /* put any nodes onto format_list in opposite way */      format_node *travler;      travler = fmt_walk;      fmt_walk = fmt_walk->next;      travler->next = format_list;      format_list = travler;    }    sf_walk = sf_walk->next;  }  /* merge sorting info of sf_list into sort_list here */  sf_walk = sf_list;  while(sf_walk){    sort_node *srt_walk;    srt_walk = sf_walk->s_cooked;    sf_walk->s_cooked = NULL;    while(srt_walk){   /* put any nodes onto sort_list in opposite way */      sort_node *travler;      travler = srt_walk;      srt_walk = srt_walk->next;      travler->next = sort_list;      sort_list = travler;    }    sf_walk = sf_walk->next;  }  if(format_list){    if(format_flags) return "Conflicting format options.";    option_source = 1;  }else{    const char *spec;    switch(format_flags){    default:             return "Conflicting format options.";    /* These can be NULL, which enables SysV list generation code. */    case 0:              spec=NULL;           break;    case FF_Uf | FF_Ul:  spec=sysv_fl_format; break;    case FF_Uf:          spec=sysv_f_format;  break;    case FF_Ul:          spec=sysv_l_format;  break;    /* These are NOT REACHED for normal -j processing. */    case FF_Uj:          spec=sysv_j_format;  break; /* Debian & Digital */    case FF_Uj | FF_Ul:  spec="RD_lj";        break; /* Debian */    case FF_Uj | FF_Uf:  spec="RD_fj";        break; /* Debian */    /* These are true BSD options. */    case FF_Bj:          spec=bsd_j_format;   break;    case FF_Bl:          spec=bsd_l_format;   break;    case FF_Bs:          spec=bsd_s_format;   break;    case FF_Bu:          spec=bsd_u_format;   break;    case FF_Bv:          spec=bsd_v_format;   break;    /* These are old Linux options. Option m is overloaded. */    case FF_LX:          spec="OL_X";         break;    case FF_Lm:          spec="OL_m";         break;    /* These are FLASK security options. */    case FF_Fc:          spec="FLASK_context"; break;    case FF_Fs:          spec="FLASK_sid";     break;    }  /* end switch(format_flags) */    option_source = 0;    if(!format_flags && !format_modifiers){   /* was default */      char *tmp;      tmp = getenv("PS_FORMAT");  /* user override kills default */      if(tmp && *tmp){        const char *err;        sf_node sfn;//        spec = tmp;//        option_source = 2;        sfn.sf = tmp;        sfn.f_cooked = NULL;        err = format_parse(&sfn);        if(!err){          format_node *fmt_walk;          fmt_walk = sfn.f_cooked;          while(fmt_walk){   /* put any nodes onto format_list in opposite way */            format_node *travler;            travler = fmt_walk;            fmt_walk = fmt_walk->next;            travler->next = format_list;            format_list = travler;          }          return NULL;        }        fprintf(stderr, "Warning: $PS_FORMAT ignored. (%s)\n", err);      }    }    if(spec){      format_node *fmt_walk;      fmt_walk = do_one_spec(spec, NULL); /* use override "" for no headers */      while(fmt_walk){   /* put any nodes onto format_list in opposite way */        format_node *travler;        travler = fmt_walk;        fmt_walk = fmt_walk->next;        travler->next = format_list;        format_list = travler;      }    }else{      const char *err;      err = generate_sysv_list();      if(err) return err;      option_source = 3;    }  }  if(format_modifiers){  /* generate_sysv_list() may have cleared some bits */    format_node *fn;    if(option_source) return "Can't use output modifiers with user-defined output";    if(format_modifiers & FM_j){      fn = do_one_spec("pgid", NULL);      if(!fmt_add_after("PPID", fn)) if(!fmt_add_after("PID", fn))        return "Internal error, no PID or PPID for -j option.";      fn = do_one_spec("sid", NULL);      if(!fmt_add_after("PGID", fn)) return "Lost my PGID!";    }    if(format_modifiers & FM_y){      /* TODO: check for failure to do something, and complain if so */      fmt_delete("F");      fn = do_one_spec("rss", NULL);      if(fmt_add_after("ADDR", fn)) fmt_delete("ADDR");    }    if(format_modifiers & FM_c){      fmt_delete("%CPU"); fmt_delete("CPU"); fmt_delete("CP"); fmt_delete("C");      fmt_delete("NI");      fn = do_one_spec("class", NULL);      if(!fmt_add_after("PRI", fn))        return "Internal error, no PRI for -c option.";      fmt_delete("PRI"); /* we want a different one */      fn = do_one_spec("pri", NULL);      if(!fmt_add_after("CLS", fn)) return "Lost my CLS!";    }  }  if(!option_source){  /* OK to really muck with stuff */    format_node *fn;    /* Do personality-specific translations not covered by format_flags.     * Generally, these only get hit when personality overrides unix output.     * That (mostly?) means the Digital and Debian personalities.     */    if((personality & PER_ZAP_ADDR) && (format_flags & FF_Ul)){      fn = do_one_spec("sgi_p", NULL);      if(fmt_add_after("ADDR", fn)) fmt_delete("ADDR");    }    if((personality & PER_SANE_USER) && (format_flags & FF_Uf)){      fn = do_one_spec("user", NULL);      if(fmt_add_after("UID", fn)) fmt_delete("UID");    }  }  /* Could scan for duplicates (format and sort) here. Digital does. */  return NULL;}