Mercurial > hg > sidinfo
comparison sidinfo.c @ 155:de75385f75e2
Simplify by removing few lines of duplicate code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 26 Oct 2017 00:22:36 +0300 |
parents | e3be2ae6120e |
children | 717d143612e2 |
comparison
equal
deleted
inserted
replaced
154:5974d50bc063 | 155:de75385f75e2 |
---|---|
695 | 695 |
696 | 696 |
697 static void siPrintPSIDInfoLine(FILE *outFile, BOOL *shown, const PSFStackItem *item, const char *d_str, const int d_int) | 697 static void siPrintPSIDInfoLine(FILE *outFile, BOOL *shown, const PSFStackItem *item, const char *d_str, const int d_int) |
698 { | 698 { |
699 const PSFOption *opt = &optPSOptions[item->cmd]; | 699 const PSFOption *opt = &optPSOptions[item->cmd]; |
700 char *fmt, *str = NULL; | 700 char *fmt, *str; |
701 | 701 |
702 switch (opt->type) | 702 switch (opt->type) |
703 { | 703 { |
704 case OTYPE_INT: | 704 case OTYPE_INT: |
705 if (item->flags & OFMT_FORMAT) | 705 if (item->flags & OFMT_FORMAT) |
706 fmt = item->fmt; | 706 fmt = item->fmt; |
707 else | 707 else |
708 fmt = optHexadecimal ? "$%04x" : "%d"; | 708 fmt = optHexadecimal ? "$%04x" : "%d"; |
709 | |
710 str = siItemFormatStrPrint(fmt, opt, d_str, d_int); | |
711 break; | 709 break; |
712 | 710 |
713 case OTYPE_STR: | 711 case OTYPE_STR: |
714 if (item->flags & OFMT_FORMAT) | 712 if (item->flags & OFMT_FORMAT) |
715 fmt = item->fmt; | 713 fmt = item->fmt; |
716 else | 714 else |
717 fmt = "%s"; | 715 fmt = "%s"; |
718 | 716 break; |
719 str = siItemFormatStrPrint(fmt, opt, d_str, d_int); | 717 |
720 break; | 718 default: |
719 return; | |
721 } | 720 } |
722 | 721 |
723 siPrintFieldPrefix(outFile, opt); | 722 siPrintFieldPrefix(outFile, opt); |
724 | 723 |
724 str = siItemFormatStrPrint(fmt, opt, d_str, d_int); | |
725 if (str != NULL) | 725 if (str != NULL) |
726 fputs(str, outFile); | 726 fputs(str, outFile); |
727 | 727 |
728 siPrintFieldSeparator(outFile); | 728 siPrintFieldSeparator(outFile); |
729 th_free(str); | 729 th_free(str); |