4.104.115
Last change
on this file since 2649eef was
e41eaa88,
checked in by Joel Sherrill <joel.sherrill@…>, on 12/18/08 at 15:25:27
|
2008-12-18 Sebastian Huber <sebastian.huber@…>
- libmisc/serdbg/termios_printk.c, libmisc/serdbg/termios_printk.h:
Fixed incompatible return value.
- libmisc/cpuuse/cpuusagereport.c: Changed output format.
- libmisc/Makefile.am, libmisc/monitor/mon-editor.c: New file.
- libmisc/capture/capture-cli.c, libmisc/monitor/mon-command.c,
libmisc/monitor/mon-monitor.c, libmisc/monitor/mon-object.c,
libmisc/monitor/mon-prmisc.c, libmisc/monitor/mon-symbols.c,
libmisc/monitor/monitor.h, libmisc/shell/cat_file.c,
libmisc/shell/cmds.c, libmisc/shell/internal.h,
libmisc/shell/main_help.c, libmisc/shell/shell.c,
libmisc/shell/shell.h, libmisc/shell/shell_cmdset.c,
libmisc/shell/shell_getchar.c, libmisc/shell/str2int.c: Various global
data is now read only. Added 'const' qualifier to many pointer
parameters. It is no longer possible to remove monitor commands.
Moved monitor line editor into a separate file to avoid unnecessary
dependencies.
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | /* |
---|
2 | * Author: Fernando RUIZ CASAS |
---|
3 | * Work: fernando.ruiz@ctv.es |
---|
4 | * Home: correo@fernando-ruiz.com |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * http://www.rtems.com/license/LICENSE. |
---|
9 | * |
---|
10 | * $Id$ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifdef HAVE_CONFIG_H |
---|
14 | #include "config.h" |
---|
15 | #endif |
---|
16 | |
---|
17 | |
---|
18 | #include <rtems/shell.h> |
---|
19 | #include "internal.h" |
---|
20 | |
---|
21 | /* |
---|
22 | * str to int "0xaffe" "0b010010" "0123" "192939" |
---|
23 | */ |
---|
24 | int rtems_shell_str2int(const char * s) { |
---|
25 | int sign=1; |
---|
26 | int base=10; |
---|
27 | int value=0; |
---|
28 | int digit; |
---|
29 | |
---|
30 | if (!s) return 0; |
---|
31 | if (*s) { |
---|
32 | if (*s=='-') { |
---|
33 | sign=-1; |
---|
34 | s++; |
---|
35 | if (!*s) return 0; |
---|
36 | } |
---|
37 | if (*s=='0') { |
---|
38 | s++; |
---|
39 | switch(*s) { |
---|
40 | case 'x': |
---|
41 | case 'X': |
---|
42 | s++; |
---|
43 | base=16; |
---|
44 | break; |
---|
45 | case 'b': |
---|
46 | case 'B': |
---|
47 | s++; |
---|
48 | base=2; |
---|
49 | break; |
---|
50 | default: |
---|
51 | base=8; |
---|
52 | break; |
---|
53 | } |
---|
54 | } |
---|
55 | while (*s) { |
---|
56 | switch(*s) { |
---|
57 | case '0': |
---|
58 | case '1': |
---|
59 | case '2': |
---|
60 | case '3': |
---|
61 | case '4': |
---|
62 | case '5': |
---|
63 | case '6': |
---|
64 | case '7': |
---|
65 | case '8': |
---|
66 | case '9': |
---|
67 | digit=*s-'0'; |
---|
68 | break; |
---|
69 | case 'A': |
---|
70 | case 'B': |
---|
71 | case 'C': |
---|
72 | case 'D': |
---|
73 | case 'E': |
---|
74 | case 'F': |
---|
75 | digit=*s-'A'+10; |
---|
76 | break; |
---|
77 | case 'a': |
---|
78 | case 'b': |
---|
79 | case 'c': |
---|
80 | case 'd': |
---|
81 | case 'e': |
---|
82 | case 'f': |
---|
83 | digit=*s-'a'+10; |
---|
84 | break; |
---|
85 | default: |
---|
86 | return value*sign; |
---|
87 | } |
---|
88 | if (digit>base) |
---|
89 | return value*sign; |
---|
90 | value=value*base+digit; |
---|
91 | s++; |
---|
92 | } |
---|
93 | } |
---|
94 | return value*sign; |
---|
95 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.