Print this page
3471 cscope-fast writes constant strings when erroring


  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*      Copyright (c) 1988 AT&T     */
  23 /*        All Rights Reserved   */
  24 
  25 
  26 /*
  27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 
  31 #pragma ident   "%Z%%M% %I%     %E% SMI"
  32 
  33 /*
  34  *      cscope - interactive C symbol cross-reference
  35  *
  36  *      display functions
  37  */
  38 
  39 #include "global.h"
  40 #include "version.h"    /* FILEVERSION and FIXVERSION */
  41 #include <curses.h>       /* COLS and LINES */
  42 #include <setjmp.h>       /* jmp_buf */
  43 #include <string.h>
  44 #include <errno.h>
  45 
  46 /* see if the function column should be displayed */
  47 #define displayfcn()    (field <= ASSIGN)
  48 
  49 #define MINCOLS 68      /* minimum columns for 3 digit Lines message numbers */
  50 
  51 int     *displine;              /* screen line of displayed reference */
  52 int     disprefs;               /* displayed references */


 550         }
 551 }
 552 
 553 /* print error message on system call failure */
 554 
 555 void
 556 myperror(char *text)
 557 {
 558         char    msg[MSGLEN + 1];        /* message */
 559 
 560         (void) sprintf(msg, "%s: %s", text, strerror(errno));
 561         putmsg(msg);
 562 }
 563 
 564 /* putmsg clears the message line and prints the message */
 565 
 566 void
 567 putmsg(char *msg)
 568 {
 569         if (incurses == NO) {
 570                 *msg = tolower(*msg);
 571                 (void) fprintf(stderr, "cscope: %s\n", msg);


 572         } else {
 573                 (void) move(MSGLINE, 0);
 574                 (void) clrtoeol();
 575                 (void) addstr(msg);
 576                 (void) refresh();
 577         }
 578         (void) strncpy(lastmsg, msg, sizeof (lastmsg) - 1);
 579 }
 580 
 581 /* clearmsg2 clears the second message line */
 582 
 583 void
 584 clearmsg2(void)
 585 {
 586         if (incurses == YES) {
 587                 (void) move(MSGLINE + 1, 0);
 588                 (void) clrtoeol();
 589         }
 590 }
 591 




  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*      Copyright (c) 1988 AT&T     */
  23 /*        All Rights Reserved   */
  24 
  25 
  26 /*
  27  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 


  31 /*
  32  *      cscope - interactive C symbol cross-reference
  33  *
  34  *      display functions
  35  */
  36 
  37 #include "global.h"
  38 #include "version.h"    /* FILEVERSION and FIXVERSION */
  39 #include <curses.h>       /* COLS and LINES */
  40 #include <setjmp.h>       /* jmp_buf */
  41 #include <string.h>
  42 #include <errno.h>
  43 
  44 /* see if the function column should be displayed */
  45 #define displayfcn()    (field <= ASSIGN)
  46 
  47 #define MINCOLS 68      /* minimum columns for 3 digit Lines message numbers */
  48 
  49 int     *displine;              /* screen line of displayed reference */
  50 int     disprefs;               /* displayed references */


 548         }
 549 }
 550 
 551 /* print error message on system call failure */
 552 
 553 void
 554 myperror(char *text)
 555 {
 556         char    msg[MSGLEN + 1];        /* message */
 557 
 558         (void) sprintf(msg, "%s: %s", text, strerror(errno));
 559         putmsg(msg);
 560 }
 561 
 562 /* putmsg clears the message line and prints the message */
 563 
 564 void
 565 putmsg(char *msg)
 566 {
 567         if (incurses == NO) {
 568                 char *str = stralloc(msg);
 569                 *str = tolower(*str);
 570                 (void) fprintf(stderr, "cscope: %s\n", str);
 571                 (void) free(str);
 572         } else {
 573                 (void) move(MSGLINE, 0);
 574                 (void) clrtoeol();
 575                 (void) addstr(msg);
 576                 (void) refresh();
 577         }
 578         (void) strncpy(lastmsg, msg, sizeof (lastmsg) - 1);
 579 }
 580 
 581 /* clearmsg2 clears the second message line */
 582 
 583 void
 584 clearmsg2(void)
 585 {
 586         if (incurses == YES) {
 587                 (void) move(MSGLINE + 1, 0);
 588                 (void) clrtoeol();
 589         }
 590 }
 591