
96: struct high_level_command_type { 97: const char* name; 98: int cmd; 99: int n_arg; 100: int opt_arg; 101: } high_level_command_type[] = { 102: /* コンテキストの情報を表示する */ 103: {"PRINT_CONTEXT", CMDH_PRINT_CONTEXT, 0, 0}, 104: /* トグルに使うキーを変更する */ 105: {"CHANGE_TOGGLE", CMDH_CHANGE_TOGGLE, 1, 0}, 106: /* コンテキストを選択する */ 107: {"SELECT_CONTEXT", CMDH_SELECT_CONTEXT, 1, 0}, 108: {"RELEASE_CONTEXT", CMDH_RELEASE_CONTEXT, 0, 0}, 109: {"MAP_CLEAR", CMDH_MAP_CLEAR, 1, 0}, 110: {"MAP_EDIT", CMDH_MAP_EDIT, 3, 0}, 111: {"MAP_SELECT", CMDH_MAP_SELECT, 1, 0}, 112: {"GET_CANDIDATE", CMDH_GET_CANDIDATE, 1, 0}, 113: {"SELECT_CANDIDATE", CMDH_SELECT_CANDIDATE, 1, 0}, 114: /* バックスペースでローマ字に戻る */ 115: {"BREAK_INTO_ROMAN", CMDH_SET_BREAK_INTO_ROMAN, 1, 0}, 116: /**/ 117: {"SET_PREEDIT_MODE", CMDH_SET_PREEDIT_MODE, 1, 0}, 118: /**/ 119: {NULL, -1, 0, 0} 120: };
ハイレベルコマンドの文字列定義
806: dl = (struct _info **)xmalloc(sizeof(struct _info *) * (ne = MINIT));
メモリ確保
91: struct xtable { 92: u_short xid; 93: char *name; 94: struct xtable *nxt;
リストの宣言
4: struct list_head { 5: struct list_head *next; 6: };
単方向リストの宣言
44: { /* add at tail */ 45: p->next = NULL; 46: if (NULL != tail) 47: tail->next = p; 48: else 49: head = p; 50: tail = p; 51: }
tailに追加
53: { /* add at head */ 54: p->next = head; 55: if (NULL == tail) 56: tail = p; 57: head = p; 58: } 59: }
headに追加
15: struct list 16: { 17: struct list *next; 18: };
単方向リストの宣言
26: a->a1[i] = b->a1[i] + c->a1[i];
ポインタで表された構造体の要素に対して for文で2つの構造体の要素の和を渡している。 ITB2 by mk
7: struct foo *next;
リスト構造 : 次の構造体変数のアドレス ITB2 by mk
10: struct foo *test(struct foo *node) 11: { 12: while (node) { 13: if (bar() && !baz()) 14: break; 15: node = node->next; 16: } 17: return node; 18: }
単方向リスト ITB2 by mk
19: void __list_add(struct list_head *new, 20: struct list_head *prev, 21: struct list_head *next) 22: { 23: if (unlikely(next->prev != prev)) { 24: printk(KERN_ERR "list_add corruption. next->prev should be " 25: "prev (%p), but was %p. (next=%p).\n", 26: prev, next->prev, next); 27: BUG(); 28: } 29: if (unlikely(prev->next != next)) { 30: printk(KERN_ERR "list_add corruption. prev->next should be " 31: "next (%p), but was %p. (prev=%p).\n", 32: next, prev->next, prev); 33: BUG(); 34: } 35: next->prev = new; 36: new->next = next; 37: new->prev = prev; 38: prev->next = new; 39: }
リスト構造をつくる関数list_add() ITB2 by mk
50: void list_add(struct list_head *new, struct list_head *head) 51: { 52: __list_add(new, head, head->next); 53: }
リスト構造を使った関数の入れ子。 ITB2 by mk
62: void list_del(struct list_head *entry) 63: { 64: if (unlikely(entry->prev->next != entry)) { 65: printk(KERN_ERR "list_del corruption. prev->next should be %p, " 66: "but was %p\n", entry, entry->prev->next); 67: BUG(); 68: } 69: if (unlikely(entry->next->prev != entry)) { 70: printk(KERN_ERR "list_del corruption. next->prev should be %p, " 71: "but was %p\n", entry, entry->next->prev); 72: BUG(); 73: } 74: __list_del(entry->prev, entry->next); 75: entry->next = LIST_POISON1; 76: entry->prev = LIST_POISON2; 77: }
listadd() <==> listdel() ITB2 by mk
1: typedef struct input { 2: struct input *next; 3: } input_t;
構造体によるリスト構造 ITB2 by mk
80: while (node) 81: { 82: if (total == node->name_length 83: && strncmp (buf, node->name, total) == 0) 84: return node; 85: node = node->next; 86: }
単方向リストが用いられている。
15: struct list 16: { 17: struct list *next; 18: };
単方向リストの宣言
781: dirs[lev] = 0; 782: free(path); 783: free_dir(sav);
781:DIRS[lev]の初期化 782:Pathのメモリ領域の解放 783:再帰呼び出し?
323: void acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_node) 324: { 325: struct acpi_namespace_node *child_node = NULL; 326: u32 level = 1; 327: 328: ACPI_FUNCTION_TRACE(ns_delete_namespace_subtree); 329: 330: if (!parent_node) { 331: return_VOID; 332: } 333: 334: /* 335: * Traverse the tree of objects until we bubble back up 336: * to where we started. 337: */ 338: while (level > 0) { 339: 340: /* Get the next node in this scope (NULL if none) */ 341: 342: child_node = 343: acpi_ns_get_next_node(ACPI_TYPE_ANY, parent_node, 344: child_node); 345: if (child_node) { 346: 347: /* Found a child node - detach any attached object */ 348: 349: acpi_ns_detach_object(child_node); 350: 351: /* Check if this node has any children */ 352: 353: if (acpi_ns_get_next_node 354: (ACPI_TYPE_ANY, child_node, NULL)) { 355: /* 356: * There is at least one child of this node, 357: * visit the node 358: */ 359: level++; 360: parent_node = child_node; 361: child_node = NULL; 362: } 363: } else { 364: /* 365: * No more children of this parent node. 366: * Move up to the grandparent. 367: */ 368: level--; 369: 370: /* 371: * Now delete all of the children of this parent 372: * all at the same time. 373: */ 374: acpi_ns_delete_children(parent_node); 375: 376: /* New "last child" is this parent node */ 377: 378: child_node = parent_node; 379: 380: /* Move up the tree to the grandparent */ 381: 382: parent_node = acpi_ns_get_parent_node(parent_node); 383: } 384: } 385: 386: return_VOID;
It uses tree struct that can move up.
35: #define GTY(x) /* nothing - marker for gengtype */
これがどのように働くかを調べたり、理解するのはちょっと大変そう。gccint の 19 章か 20 章に説明があるらしいけれど。 (一度 guest で書いたのですが login してから消せたので、書直しました。と思ったがまだ login 出来ていなかったか ?
18: for (p = el; p; p = p->next)
this is a list traversal.
6: struct list 7: { 8: struct list *next; 9: int id; 10: };
単方向リストの宣言(自分自身を指すポインタを構造体のメンバに加える)
20: for (q = el; q != p; q = q->next)
Sorry, this is a test writing. by mk
14: next = node->next;
Kikouzou is used in this part.
13: p->next = q; 14: p->prev = q; 15: q->next = p; 16: q->prev = p;
毎度お馴染のnode,next,prev。 ポインタの受け渡しをしているので、課題に沿っていると思われる。 以上。
63: char *message[] = {"Hello ", "World"}; 64: int i; 65: 66: for(i = 0; i < 2; ++i) 67: printf("%s", message[i]); 68: printf("\n"); 69: }
message[0]にHelloを、message[1]にWorldを入れて、for文でmessage[i]を回して、 printfでHello Worldを表示する部分。そして最後に改行している。 配列とfor文の練習と思われる。
10: a[i] = b[i] + c[i];
for文でポインタにポインタの和を代入するコード。(ITB2 by mk)
10: for (; *p; ) 11: { 12: if (pedantic ? (*p)->viable == 1 : (*p)->viable) 13: p = &((*p)->next); 14: else 15: *p = (*p)->next; 16: }
In the if structure, it's along TANHOUKOU list.
23: struct sysfs_dirent * sd; 24: struct sysfs_dirent * parent_sd = dir->d_fsdata; 25: for (sd = (struct sysfs_dirent *)((&parent_sd->s_children)->next); 26: &sd->s_sibling != (&parent_sd->s_children); 27: sd = (struct sysfs_dirent *)sd->s_sibling.next) { 28: if (!__builtin_strcmp(sysfs_get_name(sd), name)) 29: { 30: list_del_init(&sd->s_sibling); 31: break; 32: } 33: }
In this part,tree stlucture is used.
10: Copyright (C) 2000 Network Applied Communication Laboratory, Inc. 11: Copyright (C) 2000 Information-technology Promotion Agency, Japan 12:
.
1: #! /bin/sh 2: # Guess values for system-dependent variables and create Makefiles. 3: # Generated by GNU Autoconf 2.61. 4: # 5: # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 6: # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 7: # This configure script is free software; the Free Software Foundation 8: # gives unlimited permission to copy, distribute and modify it.
おおお.かっこいい.
113: printf (_("\ 114: +---------------+\n\ 115: | Hello, world! |\n\ 116: +---------------+\n\ 117: "));
メッセージ表示部分
1: Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>. 2: You can redistribute it and/or modify it under either the terms of the GPL 3: version 2 (see the file GPL), or the conditions below:
Copyright notice
16: You should have received a copy of the GNU General Public License 17: along with this program; if not, write to the Free Software Foundation,
ゲストアカウントで書き込みテスト。