fmt.c (245610) | fmt.c (245635) |
---|---|
1/*- 2 * Copyright (c) 1992, 1993, 1994 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 --- 20 unchanged lines hidden (view full) --- 29 30#if 0 31#ifndef lint 32static char sccsid[] = "@(#)fmt.c 8.4 (Berkeley) 4/15/94"; 33#endif 34#endif 35 36#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1992, 1993, 1994 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 --- 20 unchanged lines hidden (view full) --- 29 30#if 0 31#ifndef lint 32static char sccsid[] = "@(#)fmt.c 8.4 (Berkeley) 4/15/94"; 33#endif 34#endif 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/bin/ps/fmt.c 245610 2013-01-18 18:24:40Z jhb $"); | 37__FBSDID("$FreeBSD: head/bin/ps/fmt.c 245635 2013-01-19 00:21:55Z jhb $"); |
38 39#include <sys/types.h> 40#include <sys/time.h> 41#include <sys/resource.h> 42 43#include <err.h> 44#include <limits.h> 45#include <stdio.h> --- 72 unchanged lines hidden (view full) --- 118 } else { 119 ap = shquote(argv); 120 len = strlen(ap) + maxlen + 4; 121 } 122 cp = malloc(len); 123 if (cp == NULL) 124 errx(1, "malloc failed"); 125 if (ap == NULL) { | 38 39#include <sys/types.h> 40#include <sys/time.h> 41#include <sys/resource.h> 42 43#include <err.h> 44#include <limits.h> 45#include <stdio.h> --- 72 unchanged lines hidden (view full) --- 118 } else { 119 ap = shquote(argv); 120 len = strlen(ap) + maxlen + 4; 121 } 122 cp = malloc(len); 123 if (cp == NULL) 124 errx(1, "malloc failed"); 125 if (ap == NULL) { |
126 if (showthreads && thread != NULL) { | 126 if (thread != NULL) { |
127 asprintf(&ap, "%s/%s", cmd, thread); 128 sprintf(cp, "[%.*s]", (int)maxlen, ap); 129 free(ap); 130 } else 131 sprintf(cp, "[%.*s]", (int)maxlen, cmd); 132 } else if (strncmp(cmdpart(argv[0]), cmd, maxlen) != 0) 133 sprintf(cp, "%s (%.*s)", ap, (int)maxlen, cmd); 134 else 135 strcpy(cp, ap); 136 return (cp); 137} | 127 asprintf(&ap, "%s/%s", cmd, thread); 128 sprintf(cp, "[%.*s]", (int)maxlen, ap); 129 free(ap); 130 } else 131 sprintf(cp, "[%.*s]", (int)maxlen, cmd); 132 } else if (strncmp(cmdpart(argv[0]), cmd, maxlen) != 0) 133 sprintf(cp, "%s (%.*s)", ap, (int)maxlen, cmd); 134 else 135 strcpy(cp, ap); 136 return (cp); 137} |