rem
stringlengths
0
83.5k
add
stringlengths
0
223k
context
stringlengths
10
471k
meta
stringlengths
120
236
else if (approxlib(libs[k], other, 3, libs2) == 2) { for (r = 0; r < 2; r++) {
liberties2 = approxlib(libs[k], other, 3, libs2); if (liberties2 <= 2) { for (r = 0; r < liberties2; r++) {
defend2(int str, int *move, int komaster, int kom_pos){ int color, other; int xpos; int liberties; int libs[2]; int liberties2; int libs2[6]; int moves[MAX_MOVES]; int scores[MAX_MOVES]; int num_moves = 0; int savemove = 0; int savecode = 0; int bc; int k; int r; int s; int found_read_result; Read_result *read_result; SETUP_TRACE_INFO("defend2", str); reading_node_counter++; RTRACE("trying to rescue %1m\n", str); color = board[str]; other = OTHER_COLOR(color); gg_assert(board[str] != EMPTY); gg_assert(countlib(str) == 2); if ((stackp <= depth) && (hashflags & HASH_DEFEND2)) { found_read_result = get_read_result(DEFEND2, komaster, kom_pos, &str, &read_result); if (found_read_result) { TRACE_CACHED_RESULT(*read_result); if (rr_get_result(*read_result) != 0) *move = rr_get_move(*read_result); SGFTRACE(rr_get_move(*read_result), rr_get_result(*read_result), "cached"); return rr_get_result(*read_result); } /* This data should always be recorded. */ if (read_result) { rr_set_compressed_data(*read_result, DEFEND2, komaster, kom_pos, str, stackp); } } else read_result = NULL; liberties = findlib(str, 2, libs); ASSERT1(liberties == 2, str); /* Collect moves to try in the first batch. * 1. First order liberties. * 2. Chain breaking moves. * 3. Second order liberties moving up from first line to second. * 4. Edge clamps. */ for (k = 0; k < liberties; k++) { moves[k] = libs[k]; scores[k] = 0; } num_moves = liberties; break_chain_moves(str, moves, scores, &num_moves); break_chain2_efficient_moves(str, moves, scores, &num_moves); propose_edge_moves(str, libs, liberties, moves, scores, &num_moves, color); edge_clamp(str, moves, scores, &num_moves); order_moves(str, num_moves, moves, scores, color, read_function_name); for (k = 0; k < num_moves; k++) { int new_komaster; int new_kom_pos; int ko_move; xpos = moves[k]; if (komaster_trymove(xpos, color, "defend2-A", str, komaster, kom_pos, &new_komaster, &new_kom_pos, &ko_move, stackp <= ko_depth && savecode == 0)) { if (!ko_move) { int acode = do_attack(str, NULL, new_komaster, new_kom_pos); popgo(); if (acode == 0) { SGFTRACE(xpos, WIN, "defense effective - A"); READ_RETURN(read_result, move, xpos, WIN); } /* if the move works with ko we save it, then look for something * better. */ UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, xpos); } else { if (do_attack(str, NULL, new_komaster, new_kom_pos) != WIN) { savemove = xpos; savecode = KO_B; } popgo(); } } } /* Look for backfilling moves. */ for (k = 0; k < liberties; k++) { if (is_self_atari(libs[k], other)) { liberties2 = approxlib(libs[k], color, 6, libs2); for (r = 0; r < liberties2; r++) { xpos = libs2[r]; /* Don't reconsider previously tested moves. */ for (s = 0; s < num_moves; s++) if (xpos == moves[s]) break; if (s < num_moves) continue; if (trymove(xpos, color, "defend2-C", str, komaster, kom_pos)) { int acode; /* If the newly placed stone is in atari, we give up without * fight. */ if (countlib(xpos) == 1 && countstones(xpos) > 1) acode = WIN; else acode = do_attack(str, NULL, komaster, kom_pos); popgo(); if (acode == 0) { SGFTRACE(xpos, WIN, "backfill effective"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, xpos); } } } else if (approxlib(libs[k], other, 3, libs2) == 2) { for (r = 0; r < 2; r++) { xpos = libs2[r]; /* Don't reconsider previously tested moves. */ for (s = 0; s < num_moves; s++) if (xpos == moves[s]) break; if (s < num_moves) continue; if (!is_self_atari(xpos, color) && trymove(xpos, color, "defend2-D", str, komaster, kom_pos)) { int acode = do_attack(str, NULL, komaster, kom_pos); popgo(); if (acode == 0) { SGFTRACE(xpos, WIN, "backfill effective"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, xpos); } } } } if (stackp <= depth) { for (k = 0; k < liberties; k++) { int dcode = special_rescue(str, libs[k], &xpos, komaster, kom_pos); if (dcode == WIN) { SGFTRACE(xpos, WIN, "special rescue"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } } if (stackp <= backfill_depth) { int dcode = special_rescue2(str, libs, &xpos, komaster, kom_pos); if (dcode == WIN) { SGFTRACE(xpos, WIN, "special rescue2"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } if (level >= 10 && stackp <= superstring_depth) { int dcode = superstring_breakchain(str, &xpos, komaster, kom_pos, 4); if (dcode == WIN) { SGFTRACE(xpos, WIN, "superstring_breakchain"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } /* If nothing else works, we try playing a liberty of the * super_string. */ if (level >= 10 && stackp <= superstring_depth) { int liberties; int libs[MAX_LIBERTIES + 4]; find_superstring_liberties(str, &liberties, libs, 3); for (k = 0; k < liberties; k++) { int apos = libs[k]; if (liberty_of_string(apos, str)) continue; if (trymove(apos, color, "defend2-E", str, komaster, kom_pos)) { int acode; /* If the newly placed stone is in atari, we give up without fight. */ if (countlib(apos) == 1) acode = WIN; else acode = do_attack(str, NULL, komaster, kom_pos); popgo(); if (acode == 0) { SGFTRACE(apos, WIN, "superstring liberty"); READ_RETURN(read_result, move, apos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, apos); } } /* Now we are truly desperate. Try playing second order liberties of * the superstring. */ for (k = 0; k < liberties; k++) { int apos = libs[k]; int dcode; if (liberty_of_string(apos, str)) continue; dcode = special_rescue(str, apos, &xpos, komaster, kom_pos); if (dcode == WIN) { SGFTRACE(xpos, WIN, "special rescue"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } } /* We place the more speculative moves trying to break chain links * with 2 or 3 liberties last, because these moves often are not * really relevant. */ bc = break_chain2(str, &xpos, komaster, kom_pos); if (bc == WIN) { SGFTRACE(xpos, bc, "break chain2"); READ_RETURN(read_result, move, xpos, bc); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, bc, xpos); if (stackp <= backfill2_depth) { bc = break_chain3(str, &xpos, komaster, kom_pos); if (bc == WIN) { SGFTRACE(xpos, bc, "break chain3"); READ_RETURN(read_result, move, xpos, bc); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, bc, xpos); } if (savecode != 0) { SGFTRACE(savemove, savecode, "saved move"); READ_RETURN(read_result, move, savemove, savecode); } RTRACE("failed to find rescuing move.\n"); SGFTRACE(0, 0, NULL); READ_RETURN0(read_result);}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/7305d0ec63a021f1a105cfbef2e4a2bb4a7e8b76/reading.c/buggy/engine/reading.c
defend2(int str, int *move, int komaster, int kom_pos){ int color, other; int xpos; int liberties; int libs[2]; int liberties2; int libs2[6]; int moves[MAX_MOVES]; int scores[MAX_MOVES]; int num_moves = 0; int savemove = 0; int savecode = 0; int bc; int k; int r; int s; int found_read_result; Read_result *read_result; SETUP_TRACE_INFO("defend2", str); reading_node_counter++; RTRACE("trying to rescue %1m\n", str); color = board[str]; other = OTHER_COLOR(color); gg_assert(board[str] != EMPTY); gg_assert(countlib(str) == 2); if ((stackp <= depth) && (hashflags & HASH_DEFEND2)) { found_read_result = get_read_result(DEFEND2, komaster, kom_pos, &str, &read_result); if (found_read_result) { TRACE_CACHED_RESULT(*read_result); if (rr_get_result(*read_result) != 0) *move = rr_get_move(*read_result); SGFTRACE(rr_get_move(*read_result), rr_get_result(*read_result), "cached"); return rr_get_result(*read_result); } /* This data should always be recorded. */ if (read_result) { rr_set_compressed_data(*read_result, DEFEND2, komaster, kom_pos, str, stackp); } } else read_result = NULL; liberties = findlib(str, 2, libs); ASSERT1(liberties == 2, str); /* Collect moves to try in the first batch. * 1. First order liberties. * 2. Chain breaking moves. * 3. Second order liberties moving up from first line to second. * 4. Edge clamps. */ for (k = 0; k < liberties; k++) { moves[k] = libs[k]; scores[k] = 0; } num_moves = liberties; break_chain_moves(str, moves, scores, &num_moves); break_chain2_efficient_moves(str, moves, scores, &num_moves); propose_edge_moves(str, libs, liberties, moves, scores, &num_moves, color); edge_clamp(str, moves, scores, &num_moves); order_moves(str, num_moves, moves, scores, color, read_function_name); for (k = 0; k < num_moves; k++) { int new_komaster; int new_kom_pos; int ko_move; xpos = moves[k]; if (komaster_trymove(xpos, color, "defend2-A", str, komaster, kom_pos, &new_komaster, &new_kom_pos, &ko_move, stackp <= ko_depth && savecode == 0)) { if (!ko_move) { int acode = do_attack(str, NULL, new_komaster, new_kom_pos); popgo(); if (acode == 0) { SGFTRACE(xpos, WIN, "defense effective - A"); READ_RETURN(read_result, move, xpos, WIN); } /* if the move works with ko we save it, then look for something * better. */ UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, xpos); } else { if (do_attack(str, NULL, new_komaster, new_kom_pos) != WIN) { savemove = xpos; savecode = KO_B; } popgo(); } } } /* Look for backfilling moves. */ for (k = 0; k < liberties; k++) { if (is_self_atari(libs[k], other)) { liberties2 = approxlib(libs[k], color, 6, libs2); for (r = 0; r < liberties2; r++) { xpos = libs2[r]; /* Don't reconsider previously tested moves. */ for (s = 0; s < num_moves; s++) if (xpos == moves[s]) break; if (s < num_moves) continue; if (trymove(xpos, color, "defend2-C", str, komaster, kom_pos)) { int acode; /* If the newly placed stone is in atari, we give up without * fight. */ if (countlib(xpos) == 1 && countstones(xpos) > 1) acode = WIN; else acode = do_attack(str, NULL, komaster, kom_pos); popgo(); if (acode == 0) { SGFTRACE(xpos, WIN, "backfill effective"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, xpos); } } } else if (approxlib(libs[k], other, 3, libs2) == 2) { for (r = 0; r < 2; r++) { xpos = libs2[r]; /* Don't reconsider previously tested moves. */ for (s = 0; s < num_moves; s++) if (xpos == moves[s]) break; if (s < num_moves) continue; if (!is_self_atari(xpos, color) && trymove(xpos, color, "defend2-D", str, komaster, kom_pos)) { int acode = do_attack(str, NULL, komaster, kom_pos); popgo(); if (acode == 0) { SGFTRACE(xpos, WIN, "backfill effective"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, xpos); } } } } if (stackp <= depth) { for (k = 0; k < liberties; k++) { int dcode = special_rescue(str, libs[k], &xpos, komaster, kom_pos); if (dcode == WIN) { SGFTRACE(xpos, WIN, "special rescue"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } } if (stackp <= backfill_depth) { int dcode = special_rescue2(str, libs, &xpos, komaster, kom_pos); if (dcode == WIN) { SGFTRACE(xpos, WIN, "special rescue2"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } if (level >= 10 && stackp <= superstring_depth) { int dcode = superstring_breakchain(str, &xpos, komaster, kom_pos, 4); if (dcode == WIN) { SGFTRACE(xpos, WIN, "superstring_breakchain"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } /* If nothing else works, we try playing a liberty of the * super_string. */ if (level >= 10 && stackp <= superstring_depth) { int liberties; int libs[MAX_LIBERTIES + 4]; find_superstring_liberties(str, &liberties, libs, 3); for (k = 0; k < liberties; k++) { int apos = libs[k]; if (liberty_of_string(apos, str)) continue; if (trymove(apos, color, "defend2-E", str, komaster, kom_pos)) { int acode; /* If the newly placed stone is in atari, we give up without fight. */ if (countlib(apos) == 1) acode = WIN; else acode = do_attack(str, NULL, komaster, kom_pos); popgo(); if (acode == 0) { SGFTRACE(apos, WIN, "superstring liberty"); READ_RETURN(read_result, move, apos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, apos); } } /* Now we are truly desperate. Try playing second order liberties of * the superstring. */ for (k = 0; k < liberties; k++) { int apos = libs[k]; int dcode; if (liberty_of_string(apos, str)) continue; dcode = special_rescue(str, apos, &xpos, komaster, kom_pos); if (dcode == WIN) { SGFTRACE(xpos, WIN, "special rescue"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } } /* We place the more speculative moves trying to break chain links * with 2 or 3 liberties last, because these moves often are not * really relevant. */ bc = break_chain2(str, &xpos, komaster, kom_pos); if (bc == WIN) { SGFTRACE(xpos, bc, "break chain2"); READ_RETURN(read_result, move, xpos, bc); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, bc, xpos); if (stackp <= backfill2_depth) { bc = break_chain3(str, &xpos, komaster, kom_pos); if (bc == WIN) { SGFTRACE(xpos, bc, "break chain3"); READ_RETURN(read_result, move, xpos, bc); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, bc, xpos); } if (savecode != 0) { SGFTRACE(savemove, savecode, "saved move"); READ_RETURN(read_result, move, savemove, savecode); } RTRACE("failed to find rescuing move.\n"); SGFTRACE(0, 0, NULL); READ_RETURN0(read_result);}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/7305d0ec63a021f1a105cfbef2e4a2bb4a7e8b76/reading.c/buggy/engine/reading.c
}
}
defend2(int str, int *move, int komaster, int kom_pos){ int color, other; int xpos; int liberties; int libs[2]; int liberties2; int libs2[6]; int moves[MAX_MOVES]; int scores[MAX_MOVES]; int num_moves = 0; int savemove = 0; int savecode = 0; int bc; int k; int r; int s; int found_read_result; Read_result *read_result; SETUP_TRACE_INFO("defend2", str); reading_node_counter++; RTRACE("trying to rescue %1m\n", str); color = board[str]; other = OTHER_COLOR(color); gg_assert(board[str] != EMPTY); gg_assert(countlib(str) == 2); if ((stackp <= depth) && (hashflags & HASH_DEFEND2)) { found_read_result = get_read_result(DEFEND2, komaster, kom_pos, &str, &read_result); if (found_read_result) { TRACE_CACHED_RESULT(*read_result); if (rr_get_result(*read_result) != 0) *move = rr_get_move(*read_result); SGFTRACE(rr_get_move(*read_result), rr_get_result(*read_result), "cached"); return rr_get_result(*read_result); } /* This data should always be recorded. */ if (read_result) { rr_set_compressed_data(*read_result, DEFEND2, komaster, kom_pos, str, stackp); } } else read_result = NULL; liberties = findlib(str, 2, libs); ASSERT1(liberties == 2, str); /* Collect moves to try in the first batch. * 1. First order liberties. * 2. Chain breaking moves. * 3. Second order liberties moving up from first line to second. * 4. Edge clamps. */ for (k = 0; k < liberties; k++) { moves[k] = libs[k]; scores[k] = 0; } num_moves = liberties; break_chain_moves(str, moves, scores, &num_moves); break_chain2_efficient_moves(str, moves, scores, &num_moves); propose_edge_moves(str, libs, liberties, moves, scores, &num_moves, color); edge_clamp(str, moves, scores, &num_moves); order_moves(str, num_moves, moves, scores, color, read_function_name); for (k = 0; k < num_moves; k++) { int new_komaster; int new_kom_pos; int ko_move; xpos = moves[k]; if (komaster_trymove(xpos, color, "defend2-A", str, komaster, kom_pos, &new_komaster, &new_kom_pos, &ko_move, stackp <= ko_depth && savecode == 0)) { if (!ko_move) { int acode = do_attack(str, NULL, new_komaster, new_kom_pos); popgo(); if (acode == 0) { SGFTRACE(xpos, WIN, "defense effective - A"); READ_RETURN(read_result, move, xpos, WIN); } /* if the move works with ko we save it, then look for something * better. */ UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, xpos); } else { if (do_attack(str, NULL, new_komaster, new_kom_pos) != WIN) { savemove = xpos; savecode = KO_B; } popgo(); } } } /* Look for backfilling moves. */ for (k = 0; k < liberties; k++) { if (is_self_atari(libs[k], other)) { liberties2 = approxlib(libs[k], color, 6, libs2); for (r = 0; r < liberties2; r++) { xpos = libs2[r]; /* Don't reconsider previously tested moves. */ for (s = 0; s < num_moves; s++) if (xpos == moves[s]) break; if (s < num_moves) continue; if (trymove(xpos, color, "defend2-C", str, komaster, kom_pos)) { int acode; /* If the newly placed stone is in atari, we give up without * fight. */ if (countlib(xpos) == 1 && countstones(xpos) > 1) acode = WIN; else acode = do_attack(str, NULL, komaster, kom_pos); popgo(); if (acode == 0) { SGFTRACE(xpos, WIN, "backfill effective"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, xpos); } } } else if (approxlib(libs[k], other, 3, libs2) == 2) { for (r = 0; r < 2; r++) { xpos = libs2[r]; /* Don't reconsider previously tested moves. */ for (s = 0; s < num_moves; s++) if (xpos == moves[s]) break; if (s < num_moves) continue; if (!is_self_atari(xpos, color) && trymove(xpos, color, "defend2-D", str, komaster, kom_pos)) { int acode = do_attack(str, NULL, komaster, kom_pos); popgo(); if (acode == 0) { SGFTRACE(xpos, WIN, "backfill effective"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, xpos); } } } } if (stackp <= depth) { for (k = 0; k < liberties; k++) { int dcode = special_rescue(str, libs[k], &xpos, komaster, kom_pos); if (dcode == WIN) { SGFTRACE(xpos, WIN, "special rescue"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } } if (stackp <= backfill_depth) { int dcode = special_rescue2(str, libs, &xpos, komaster, kom_pos); if (dcode == WIN) { SGFTRACE(xpos, WIN, "special rescue2"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } if (level >= 10 && stackp <= superstring_depth) { int dcode = superstring_breakchain(str, &xpos, komaster, kom_pos, 4); if (dcode == WIN) { SGFTRACE(xpos, WIN, "superstring_breakchain"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } /* If nothing else works, we try playing a liberty of the * super_string. */ if (level >= 10 && stackp <= superstring_depth) { int liberties; int libs[MAX_LIBERTIES + 4]; find_superstring_liberties(str, &liberties, libs, 3); for (k = 0; k < liberties; k++) { int apos = libs[k]; if (liberty_of_string(apos, str)) continue; if (trymove(apos, color, "defend2-E", str, komaster, kom_pos)) { int acode; /* If the newly placed stone is in atari, we give up without fight. */ if (countlib(apos) == 1) acode = WIN; else acode = do_attack(str, NULL, komaster, kom_pos); popgo(); if (acode == 0) { SGFTRACE(apos, WIN, "superstring liberty"); READ_RETURN(read_result, move, apos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, acode, apos); } } /* Now we are truly desperate. Try playing second order liberties of * the superstring. */ for (k = 0; k < liberties; k++) { int apos = libs[k]; int dcode; if (liberty_of_string(apos, str)) continue; dcode = special_rescue(str, apos, &xpos, komaster, kom_pos); if (dcode == WIN) { SGFTRACE(xpos, WIN, "special rescue"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, dcode, xpos); } } /* We place the more speculative moves trying to break chain links * with 2 or 3 liberties last, because these moves often are not * really relevant. */ bc = break_chain2(str, &xpos, komaster, kom_pos); if (bc == WIN) { SGFTRACE(xpos, bc, "break chain2"); READ_RETURN(read_result, move, xpos, bc); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, bc, xpos); if (stackp <= backfill2_depth) { bc = break_chain3(str, &xpos, komaster, kom_pos); if (bc == WIN) { SGFTRACE(xpos, bc, "break chain3"); READ_RETURN(read_result, move, xpos, bc); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, bc, xpos); } if (savecode != 0) { SGFTRACE(savemove, savecode, "saved move"); READ_RETURN(read_result, move, savemove, savecode); } RTRACE("failed to find rescuing move.\n"); SGFTRACE(0, 0, NULL); READ_RETURN0(read_result);}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/7305d0ec63a021f1a105cfbef2e4a2bb4a7e8b76/reading.c/buggy/engine/reading.c
/* If there is a neighbor in atari, we also try back-capturing. */ for (r = 0; r < 4; r++) { int bpos = libs2[0] + delta[r]; if (board[bpos] == other && chainlinks2(bpos, adjs, 1) > 0) { /* FIXME: If there is more than one neighbor in atari, we * currently just take one randomly. This is maybe not good * enough. We might also want to check against snapback. */ findlib(adjs[0], 1, &xpos); ADD_CANDIDATE_MOVE(xpos, 0, moves, scores, num_moves); } }
attack2(int str, int *move, int komaster, int kom_pos){ int color = board[str]; int other = OTHER_COLOR(color); int apos; int hpos; int xpos; int liberties, r; int libs[2]; int libs2[2]; int adj, adjs[MAXCHAIN]; int savemove = 0; int savecode = 0; int acode; int dcode; int k; int atari_possible = 0; int moves[MAX_MOVES]; int scores[MAX_MOVES]; int num_moves = 0; int adjacent_liberties = 0; int found_read_result; Read_result *read_result; SETUP_TRACE_INFO("attack2", str); reading_node_counter++; str = find_origin(str); ASSERT1(board[str] != EMPTY, str); ASSERT1(countlib(str) == 2, str); RTRACE("checking attack on %1m with 2 liberties\n", str); if ((stackp <= depth) && (hashflags & HASH_ATTACK2)) { found_read_result = get_read_result(ATTACK2, komaster, kom_pos, &str, &read_result); if (found_read_result) { TRACE_CACHED_RESULT(*read_result); if (rr_get_result(*read_result) != 0) *move = rr_get_move(*read_result); SGFTRACE(rr_get_move(*read_result), rr_get_result(*read_result), "cached"); return rr_get_result(*read_result); } /* This data should always be recorded. */ if (read_result) { rr_set_compressed_data(*read_result, ATTACK2, komaster, kom_pos, str, stackp); } } else read_result = NULL; /* The attack may fail if a boundary string is in atari and cannot * be defended. First we must try defending such a string. * * We start by trying to defend the boundary string by looking for an * adjacent string which is in atari. */ adj = chainlinks2(str, adjs, 1); for (r = 0; r < adj; r++) { /* if stackp > depth and any boundary chain is in atari, assume safe. * However, if the captured chain is only of size 1, there can still * be a working ladder, so continue if that is the case. */ if (stackp > depth && countstones(adjs[r]) > 1) { SGFTRACE(0, 0, "boundary in atari"); READ_RETURN0(read_result); } /* Pick up moves breaking the second order chain. */ if (stackp <= depth) break_chain_moves(adjs[r], moves, scores, &num_moves); findlib(adjs[r], 1, &hpos); ADD_CANDIDATE_MOVE(hpos, 0, moves, scores, num_moves); } /* Get the two liberties of (str). */ liberties = findlib(str, 2, libs); ASSERT1(liberties == 2, str); if (libs[0] == SOUTH(libs[1]) || libs[0] == WEST(libs[1]) || libs[0] == NORTH(libs[1]) || libs[0] == EAST(libs[1])) adjacent_liberties = 1; for (k = 0; k < 2; k++) { apos = libs[k]; if (!is_self_atari(apos, other)) atari_possible = 1; /* we only want to consider the move at (apos) if: * stackp <= backfill_depth * -or- stackp <= depth and it is an isolated stone * -or- it is not in immediate atari */ if (stackp <= backfill_depth || ((stackp <= depth || adjacent_liberties) && board[SOUTH(apos)] != other && board[WEST(apos)] != other && board[NORTH(apos)] != other && board[EAST(apos)] != other) || !is_self_atari(apos, other)) ADD_CANDIDATE_MOVE(apos, 0, moves, scores, num_moves); /* Try backfilling if atari is impossible. */ if (stackp <= backfill_depth && approxlib(apos, other, 2, libs2) == 1) { ADD_CANDIDATE_MOVE(libs2[0], 0, moves, scores, num_moves); } } /* If we can't make a direct atari, look for edge blocking moves. */ if (!atari_possible) for (k = 0; k < 2; k++) edge_block(str, libs[k], moves, scores, &num_moves); /* If one of the surrounding chains have only two liberties, which * coincide with the liberties of the attacked string, we try to * backcapture. */ adj = chainlinks2(str, adjs, 2); for (r = 0; r < adj; r++) { apos = adjs[r]; if (liberty_of_string(libs[0], apos) && liberty_of_string(libs[1], apos)) break_chain_moves(apos, moves, scores, &num_moves); } propose_edge_moves(str, libs, liberties, moves, scores, &num_moves, other); order_moves(str, num_moves, moves, scores, other, read_function_name); for (k = 0; k < num_moves; k++) { int new_komaster; int new_kom_pos; int ko_move; apos = moves[k]; if (komaster_trymove(apos, other, "attack2-A", str, komaster, kom_pos, &new_komaster, &new_kom_pos, &ko_move, stackp <= ko_depth && savecode == 0)) { if (!ko_move) { dcode = do_find_defense(str, NULL, new_komaster, new_kom_pos); if (dcode != WIN && do_attack(str, NULL, new_komaster, new_kom_pos)) { if (dcode == 0) { popgo(); SGFTRACE(apos, WIN, "attack effective"); READ_RETURN(read_result, move, apos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, dcode, apos); } } else { if (do_find_defense(str, NULL, new_komaster, new_kom_pos) != WIN && do_attack(str, NULL, new_komaster, new_kom_pos) != 0) { savemove = apos; savecode = KO_B; } } popgo(); } } /* The simple ataris didn't work. Try something more fancy. */ acode = find_cap2(str, libs[0], libs[1], &xpos, komaster, kom_pos); if (acode == WIN) { SGFTRACE(xpos, WIN, "find cap2"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, acode, xpos); if (stackp <= backfill_depth) { acode = special_attack2(str, libs, &xpos, komaster, kom_pos); if (acode == WIN) { SGFTRACE(xpos, WIN, "special attack2"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, acode, xpos); } if (stackp <= backfill_depth) { acode = special_attack3(str, libs, &xpos, komaster, kom_pos); if (acode == WIN) { SGFTRACE(xpos, WIN, "special attack3"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, acode, xpos); } if (stackp <= backfill_depth) { acode = special_attack4(str, libs, &xpos, komaster, kom_pos); if (acode == WIN) { SGFTRACE(xpos, WIN, "special attack4"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT_UNREVERSED(savecode, savemove, acode, xpos); } /* If it is not possible to make a direct atari, we try filling * a liberty of the superstring. */ if (level >= 10 && stackp <= backfill_depth && (stackp <= superstring_depth || !atari_possible)) { int liberties; int libs[MAX_LIBERTIES + 4]; int liberty_cap = 2; if (stackp <= backfill2_depth) liberty_cap = 3; find_superstring_liberties(str, &liberties, libs, liberty_cap); if (liberties <= 5) { for (k = 0; k < liberties; k++) { int apos = libs[k]; if (liberty_of_string(apos, str)) continue; if (trymove(apos, other, "attack2-C", str, komaster, kom_pos)) { if (countlib(apos) == 1) { /* can't atari, try backfilling. */ findlib(apos, 1, &xpos); if (approxlib(xpos, other, 2, NULL) > 1) { popgo(); if (trymove(xpos, other, "attack2-D", str, komaster, kom_pos)) { dcode = do_find_defense(str, NULL, komaster, kom_pos); if (dcode != WIN && do_attack(str, NULL, komaster, kom_pos)) { if (dcode == 0) { popgo(); SGFTRACE(xpos, WIN, "attack effective"); READ_RETURN(read_result, move, xpos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, dcode, xpos); } popgo(); } } else popgo(); } else { dcode = do_find_defense(str, NULL, komaster, kom_pos); if (dcode != WIN && do_attack(str, NULL, komaster, kom_pos)) { if (dcode == 0) { popgo(); SGFTRACE(apos, WIN, "attack effective"); READ_RETURN(read_result, move, apos, WIN); } UPDATE_SAVED_KO_RESULT(savecode, savemove, dcode, apos); } popgo(); } } } } } if (savecode == 0) { RTRACE("ALIVE!!\n"); SGFTRACE(0, 0, NULL); READ_RETURN0(read_result); } SGFTRACE(savemove, savecode, "saved move"); READ_RETURN(read_result, move, savemove, savecode);}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/7305d0ec63a021f1a105cfbef2e4a2bb4a7e8b76/reading.c/buggy/engine/reading.c
trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (i==V('A','t')) out_html("AT&amp;T Unix ");
case V('U','x'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (i==V('A','t')) out_html("AT&amp;T UNIX ");
static char *scan_request(char *c){ /* BSD Mandoc stuff */ static int mandoc_synopsis=0; /* True if we are in the synopsis section */ static int mandoc_command=0; /* True if this is mandoc page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ int i,j,mode=0; char *h; char *wordlist[MAX_WORDLIST]; int words; char *sl; STRDEF *owndef; while (*c==' ' || *c=='\t') c++; if (c[0]=='\n') return c+1; if (c[1]=='\n') j=1; else j=2; while (c[j]==' ' || c[j]=='\t') j++; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') c=skip_till_newline(c); else c = scan_escape(c+1); } else { i=V(c[0],c[1]); switch (i) { case V('a','b'): h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; puts(buffer); } /* fprintf(stderr, "%s\n", c+2); */ return 0; break; case V('d','i'): { STRDEF *de; /* int oldcurpos=curpos; */ c=c+j; i=V(c[0],c[1]); if (*c=='\n') { c++;break; } while (*c && *c!='\n') c++; c++; h=c; while (*c && strncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; de=strdef; while (de && de->nr !=i) de=de->next; if (!de) { de=new STRDEF(); de->nr=i; de->slen=0; de->next=strdef; de->st=NULL; strdef=de; } else { delete [] de->st; de->slen=0; de->st=NULL; } scan_troff(h,0,&de->st); if (*c) *c='.'; while (*c && *c++!='\n'); break; } case V('d','s'): mode=1; case V('a','s'): { STRDEF *de; int oldcurpos=curpos; c=c+j; i=V(c[0],c[1]); j=0; while (c[j] && c[j]!='\n') j++; if (j<3) { c=c+j; break; } if (c[1]==' ') c=c+1; else c=c+2; while (isspace(*c)) c++; if (*c=='"') c++; de=strdef; while (de && de->nr != i) de=de->next; single_escape=1; curpos=0; if (!de) { char *h; de=new STRDEF(); de->nr=i; de->slen=0; de->next=strdef; de->st=NULL; strdef=de; h=NULL; c=scan_troff(c, 1, &h); de->st=h; de->slen=curpos; } else { if (mode) { char *h=NULL; c=scan_troff(c, 1, &h); delete [] de->st; de->slen=0; de->st=h; } else c=scan_troff(c,1,&de->st); de->slen+=curpos; } single_escape=0; curpos=oldcurpos; } break; case V('b','r'): if (still_dd) out_html("<DD>"); else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) { c=scan_escape(c+1); } c=skip_till_newline(c);break; case V('c','2'): c=c+j; if (*c!='\n') { nobreaksym=*c; } else nobreaksym='\''; c=skip_till_newline(c); break; case V('c','c'): c=c+j; if (*c!='\n') { controlsym=*c; } else controlsym='.'; c=skip_till_newline(c); break; case V('c','e'): c=c+j; if (*c=='\n') { i=1; } else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && strncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; case V('e','c'): c=c+j; if (*c!='\n') { escapesym=*c; } else escapesym='\\'; break; c=skip_till_newline(c); case V('e','o'): escapesym='\0'; c=skip_till_newline(c); break; case V('e','x'): return 0; break; case V('f','c'): c=c+j; if (*c=='\n') { fieldsym=padsym='\0'; } else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; case V('f','i'): if (!fillout) { out_html(change_to_font(0)); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; case V('f','t'): c=c+j; if (*c=='\n') { out_html(change_to_font(0)); } else { if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(change_to_font(fn)); } else { out_html(change_to_font(*c)); c++; } } c=skip_till_newline(c); break; case V('e','l'): { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case V('i','e'): /* .ie c anything : then part of if else */ case V('i','f'): { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); int ifelseval=!i; s_ifelseval.push( ifelseval ); if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case V('i','g'): { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && strncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case V('n','f'): if (fillout) { out_html(change_to_font(0)); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; case V('p','s'): c=c+j; if (*c=='\n') { out_html(change_to_size('0')); } else { j=0;i=0; if (*c=='-') { j= -1;c++; } else if (*c=='+') { j=1;c++;} c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; case V('s','p'): c=c+j; if (fillout) out_html("<P>"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; case V('s','o'): { /* FILE *f; */ char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') { h=c; } else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { fprintf(stderr, "man2html: unable to open or read file %s.\n", h); out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else { scan_troff(buf+1,0,NULL); } if (buf) delete [] buf; if (name) delete [] name; *c++='\n'; break; } case V('t','a'): c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; case V('t','i'): /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; case V('t','m'): c=c+j; h=c; while (*c!='\n') c++; *c='\0'; /* fprintf(stderr,"%s\n", h); */ *c='\n'; break; case V('B',' '): case V('B','\n'): case V('I',' '): case V('I','\n'): /* parse one line in a certain font */ out_html(change_to_font(*c)); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('F','d'): //for "Function definitions", mdoc package case V('F','n'): //for "Function calls": brackets and commas have to be inserted automatically case V('F','o'): case V('F','c'): { bool inFdMode=(c[1]=='d'); char font[2] ; font[0] = 'B'; font[1] = 'B'; c=c+j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words); c=sl+1; /* .BR name (section) ** indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(change_to_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (inFdMode) continue; if (i==0) { out_html(" ("); if (!mandoc_synopsis) out_html(") "); } else if (i<words-1) out_html(", "); } if (mandoc_synopsis) { if (!inFdMode) out_html(");"); out_html("<br>"); }; out_html(change_to_font('R')); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; }; break; case V('O','P'): /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=1; c[0]='B'; c[1]='I'; out_html(change_to_font('R')); out_html("["); curpos++; case V('F','t'): //perhaps "Function return type" case V('F','a'): //"Function argument" case V('B','R'): case V('B','I'): case V('I','B'): case V('I','R'): case V('R','B'): case V('R','I'): { bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words); c=sl+1; /* .BR name (section) ** indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(change_to_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(change_to_font('R')); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; } break; case V('D','T'): for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; case V('I','P'): sl=fill_words(c+j, wordlist, &words); c=sl+1; if (!dl_set[itemdepth]) { out_html("<DL COMPACT>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) { scan_troff(wordlist[0], 1,NULL); } out_html("<DD>"); curpos=0; break; case V('T','P'): if (!dl_set[itemdepth]) { out_html("<P><DL COMPACT>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=1; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; case V('I','X'): /* general index */ c=skip_till_newline(c); break; case V('P',' '): case V('P','\n'): case V('L','P'): case V('P','P'): if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<P>\n"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; case V('H','P'): if (!dl_set[itemdepth]) { out_html("<DL COMPACT>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=1; c=skip_till_newline(c); curpos=0; break; case V('P','D'): c=skip_till_newline(c); break; case V('R','s'): /* BSD mandoc */ case V('R','S'): sl=fill_words(c+j, wordlist, &words); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL COMPACT><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } case V('R','e'): /* BSD mandoc */ case V('R','E'): if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; case V('S','B'): out_html(change_to_size(-1)); out_html(change_to_font('B')); c=scan_troff(c+j, 1, NULL); out_html(change_to_font('R')); out_html(change_to_size('0')); break; case V('S','M'): c=c+j; if (*c=='\n') c++; out_html(change_to_size(-1)); trans_char(c,'"','\a'); c=scan_troff(c,1,NULL); out_html(change_to_size('0')); break; case V('S','s'): /* BSD mandoc */ mandoc_command = 1; case V('S','S'): mode=1; case V('S','h'): /* BSD mandoc */ /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case V('S','H'): c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(change_to_font(0)); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); /* &nbsp; for mosaic users */ if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = strncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; case V('S','x'): // reference to a section header out_html(change_to_font('B')); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('T','S'): c=scan_table(c); break; case V('D','t'): /* BSD mandoc */ mandoc_command = 1; case V('T','H'): if (!output_possible) { sl = fill_words(c+j, wordlist, &words); if (words>1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; output_possible=1; out_html( DOCTYPE"<HTML><HEAD><TITLE>Manpage of "); out_html( wordlist[0]); out_html( "</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\"KDE_COMMON_DIR/kde-default.css\" type=\"text/css\">\n" ); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div id=\"headline\" style=\"position : absolute; height : 85px; z-index :\n" ); out_html("100; background : transparent; text-align : center; text-transform:\n" ); out_html("smallcaps; width : 100%; top : 0px; left : 0px; width : 100%; color :\n" ); out_html("#000000;\">\n" ); out_html("\n" ); out_html("<H1>" ); out_html( wordlist[0] ); out_html("</H1>\n" ); out_html("</div>\n" ); out_html("<div id=\"navbackground\" style=\"position : absolute; width : 100%; height\n" ); out_html(": 124px; background-image : url('KDE_COMMON_DIR/doctop2.png'); z-index : 5; left\n" ); out_html(": 0px; top : 0px; padding : 0px;\"> <div id=\"bulb1\" style=\"padding : 0px;\n" ); out_html("position : absolute; z-index : 15; width : 150px; height : 85px; top :\n" ); out_html("0px; left : 0px; background : url('KDE_COMMON_DIR/doctop1.png') repeat;\"></div>\n" ); out_html("<div id=\"gradient\" style=\"position : absolute; width : 275px; height :\n" ); out_html("85px; z-index : 19px; top : 0px; padding : 0px; left : 150px;\n" ); out_html("background-image : url('KDE_COMMON_DIR/doctop1a.png'); background-repeat :\n" ); out_html("no-repeat; background-color : transparent; visibility : visible;\"></div>\n" ); out_html("\n" ); out_html("<div id=\"bulb-bit\" style=\"position : absolute; width : 100%; height :\n" ); out_html("25px; top : 85px; left : 0px; background-image :\n" ); out_html("url('KDE_COMMON_DIR/doctop1b.png'); background-repeat : no-repeat;\n" ); out_html("background-color : transparent; z-index : 5;\"></div></div>\n" ); out_html("<h1>" ); out_html( wordlist[0] ); out_html( "</h1>\n" ); out_html("\n" ); out_html("Section: " ); if (words>4) out_html(wordlist[4]); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(wordlist[1]); out_html(")\n"); *sl='\n'; if (mandoc_command) out_html("<BR>BSD mandoc<BR>"); } c=sl+1; } else c=skip_till_newline(c); curpos=0; break; case V('T','X'): { sl=fill_words(c+j, wordlist, &words); *sl='\0'; out_html(change_to_font('I')); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=strlen(c2); out_html(c2); out_html(change_to_font('R')); if (words>1) out_html(wordlist[1]); *sl='\n'; c=sl+1; } break; case V('r','m'): /* .rm xx : Remove request, macro or string */ case V('r','n'): /* .rn xx yy : Rename request, macro or string xx to yy */ { STRDEF *de; c=c+j; i=V(c[0],c[1]); c=c+2; while (isspace(*c) && *c!='\n') c++; j=V(c[0],c[1]); while (*c && *c!='\n') c++; c++; de=strdef; while (de && de->nr!=j) de=de->next; if (de) { delete [] de->st; de->st=0; de->nr=0; } de=strdef; while (de && de->nr!=i) de=de->next; if (de) de->nr=j; break; } case V('n','x'): /* .nx filename : next file. */ case V('i','n'): /* .in +-N : Indent */ c=skip_till_newline(c); break; case V('n','r'): /* .nr R +-N M: define and set number register R by +-N; ** auto-increment by M */ { INTDEF *intd; c=c+j; i=V(c[0],c[1]); c=c+2; intd=intdef; while (intd && intd->nr!=i) intd=intd->next; if (!intd) { intd = new INTDEF(); intd->nr=i; intd->val=0; intd->incr=0; intd->next=intdef; intdef=intd; } while (*c==' ' || *c=='\t') c++; c=scan_expression(c,&intd->val); if (*c!='\n') { while (*c==' ' || *c=='\t') c++; c=scan_expression(c,&intd->incr); } c=skip_till_newline(c); break; } case V('a','m'): /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=1; case V('d','e'): /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { STRDEF *de; int olen=0; char c2; c=c+j; sl=fill_words(c, wordlist, &words); c2 = c[1]; if (c2 == '\n') c2 = ' '; i=V(c[0],c2);j=2; if (words==1) { wordlist[1] = qstrdup(".."); } else { wordlist[1]--; wordlist[1][0]='.'; j=3; } c=sl+1; sl=c; while (*c && strncmp(c,wordlist[1],j)) c=skip_till_newline(c); de=defdef; while (de && de->nr!= i) de=de->next; if (mode && de) olen=strlen(de->st); j=olen+c-sl; h = stralloc(j*2+4); if (h) { for (j=0; j<olen; j++) h[j]=de->st[j]; if (!j || h[j-1]!='\n') h[j++]='\n'; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { h[j++]='\\'; sl++; } else h[j++]=*sl; sl++; } h[j]=0; if (de) { delete [] de->st; de->st=h; } else { de = new STRDEF(); de->nr=i; de->next=defdef; de->st=h; defdef=de; } } if (words==1) { delete [] wordlist[1]; } } c=skip_till_newline(c); break; case V('B','l'): /* BSD mandoc */ { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) { /* These things can nest. */ itemdepth++; } if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL COMPACT>\n"); } if (fillout) out_html("<P>\n"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; } case V('E','l'): /* BSD mandoc */ c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("</DL>\n"); } else if (dl_set[itemdepth] & BL_BULLET_LIST) { out_html("</UL>\n"); } else if (dl_set[itemdepth] & BL_ENUM_LIST) { out_html("</OL>\n"); } dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<P>\n"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; case V('I','t'): /* BSD mandoc */ c=c+j; if (strncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) { c = skip_till_newline(c); } if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(change_to_font('B')); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(change_to_font('R')); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; case V('B','k'): /* BSD mandoc */ case V('E','k'): /* BSD mandoc */ case V('D','d'): /* BSD mandoc */ case V('O','s'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('B','t'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; case V('A','t'): /* BSD mandoc */ case V('F','x'): /* BSD mandoc */ case V('N','x'): /* BSD mandoc */ case V('O','x'): /* BSD mandoc */ case V('B','x'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (i==V('A','t')) out_html("AT&amp;T Unix "); else if (i==V('F','x')) out_html("FreeBSD "); else if (i==V('N','x')) out_html("NetBSD "); else if (i==V('O','x')) out_html("OpenBSD "); else if (i==V('B','x')) out_html("BSD "); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; case V('D','l'): /* BSD mandoc */ c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); out_html(change_to_font('L')); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; case V('B','d'): /* BSD mandoc */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) { strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); } out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(change_to_font(0)); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case V('E','d'): /* BSD mandoc */ if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(change_to_font(0)); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; case V('B','e'): /* BSD mandoc */ c=c+j; if (fillout) out_html("<P>"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; case V('X','r'): /* BSD mandoc */ { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } break; case V('F','l'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; out_html("-"); if (*c!='\n') { out_html(change_to_font('B')); c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); } out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('P','a'): /* BSD mandoc */ case V('P','f'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('P','p'): /* BSD mandoc */ if (fillout) out_html("<P>\n"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; case V('D','q'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html("``"); c=scan_troff_mandoc(c, 1, NULL); out_html("''"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('O','p'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(change_to_font('R')); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('O','o'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(change_to_font('R')); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; case V('O','c'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html("]"); if (fillout) curpos++; else curpos=0; break; case V('P','q'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html("("); c=scan_troff_mandoc(c, 1, NULL); out_html(")"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('Q','l'): /* BSD mandoc */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case V('S','q'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html("`"); c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('A','r'): /* BSD mandoc */ /* parse one line in italics */ out_html(change_to_font('I')); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else { c=scan_troff_mandoc(c, 1, NULL); } out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('A','d'): /* BSD mandoc */ case V('E','m'): /* BSD mandoc */ case V('V','a'): /* BSD mandoc */ case V('X','c'): /* BSD mandoc */ /* parse one line in italics */ out_html(change_to_font('I')); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('N','d'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('N','m'): /* BSD mandoc */ { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ static int count = 0; /* Don't break on the first Nm */ if (count) { out_html("<BR>"); } else { char *end = strchr(c, '\n'); if (end) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, end - c, SMALL_STR_MAX); } } count++; } out_html(change_to_font('B')); while (*c == ' '|| *c == '\t') c++; if (*c == '\n') { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); } else { c=scan_troff_mandoc(c, 1, NULL); } out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case V('C','d'): /* BSD mandoc */ case V('C','m'): /* BSD mandoc */ case V('I','c'): /* BSD mandoc */ case V('M','s'): /* BSD mandoc */ case V('O','r'): /* BSD mandoc */ case V('S','y'): /* BSD mandoc */ /* parse one line in bold */ out_html(change_to_font('B')); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('D','v'): /* BSD mandoc */ case V('E','v'): /* BSD mandoc */ case V('F','r'): /* BSD mandoc */ case V('L','i'): /* BSD mandoc */ case V('N','o'): /* BSD mandoc */ case V('N','s'): /* BSD mandoc */ case V('T','n'): /* BSD mandoc */ case V('n','N'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(change_to_font('B')); c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('%','A'): /* BSD mandoc biblio stuff */ case V('%','D'): case V('%','N'): case V('%','O'): case V('%','P'): case V('%','Q'): case V('%','V'): c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; case V('%','B'): case V('%','J'): case V('%','R'): case V('%','T'): c=c+j; out_html(change_to_font('I')); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(change_to_font('R')); if (fillout) curpos++; else curpos=0; break; default: /* search macro database of self-defined macros */ owndef = defdef; while (owndef && owndef->nr!=i) owndef=owndef->next; if (owndef) { char **oldargument; int deflen; int onff; sl=fill_words(c+j, wordlist, &words); c=sl+1; *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) { scan_troff_mandoc(wordlist[i],1,&h); } else { scan_troff(wordlist[i],1,&h); } wordlist[i] = qstrdup(h); delete [] h; } for (i=words;i<20; i++) wordlist[i]=NULL; deflen = strlen(owndef->st); for (i=0; (owndef->st[deflen+2+i]=owndef->st[i]); i++); oldargument=argument; argument=wordlist; onff=newline_for_fun; if (mandoc_command) { scan_troff_mandoc(owndef->st+deflen+2, 0, NULL); } else { scan_troff(owndef->st+deflen+2, 0, NULL); } newline_for_fun=onff; argument=oldargument; for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; } else if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any BSD mandoc commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; strncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(change_to_font('R')); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else { c=skip_till_newline(c); } break; } } if (fillout) { out_html(NEWLINE); curpos++; } NEWLINE[0]='\n'; return c;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/473c0f88b96ea5413b7fed18dcacb7820b4d4134/man2html.cpp/buggy/kioslave/man/man2html.cpp
else if (i==V('U','x')) out_html("UNIX ");
static char *scan_request(char *c){ /* BSD Mandoc stuff */ static int mandoc_synopsis=0; /* True if we are in the synopsis section */ static int mandoc_command=0; /* True if this is mandoc page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ int i,j,mode=0; char *h; char *wordlist[MAX_WORDLIST]; int words; char *sl; STRDEF *owndef; while (*c==' ' || *c=='\t') c++; if (c[0]=='\n') return c+1; if (c[1]=='\n') j=1; else j=2; while (c[j]==' ' || c[j]=='\t') j++; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') c=skip_till_newline(c); else c = scan_escape(c+1); } else { i=V(c[0],c[1]); switch (i) { case V('a','b'): h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; puts(buffer); } /* fprintf(stderr, "%s\n", c+2); */ return 0; break; case V('d','i'): { STRDEF *de; /* int oldcurpos=curpos; */ c=c+j; i=V(c[0],c[1]); if (*c=='\n') { c++;break; } while (*c && *c!='\n') c++; c++; h=c; while (*c && strncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; de=strdef; while (de && de->nr !=i) de=de->next; if (!de) { de=new STRDEF(); de->nr=i; de->slen=0; de->next=strdef; de->st=NULL; strdef=de; } else { delete [] de->st; de->slen=0; de->st=NULL; } scan_troff(h,0,&de->st); if (*c) *c='.'; while (*c && *c++!='\n'); break; } case V('d','s'): mode=1; case V('a','s'): { STRDEF *de; int oldcurpos=curpos; c=c+j; i=V(c[0],c[1]); j=0; while (c[j] && c[j]!='\n') j++; if (j<3) { c=c+j; break; } if (c[1]==' ') c=c+1; else c=c+2; while (isspace(*c)) c++; if (*c=='"') c++; de=strdef; while (de && de->nr != i) de=de->next; single_escape=1; curpos=0; if (!de) { char *h; de=new STRDEF(); de->nr=i; de->slen=0; de->next=strdef; de->st=NULL; strdef=de; h=NULL; c=scan_troff(c, 1, &h); de->st=h; de->slen=curpos; } else { if (mode) { char *h=NULL; c=scan_troff(c, 1, &h); delete [] de->st; de->slen=0; de->st=h; } else c=scan_troff(c,1,&de->st); de->slen+=curpos; } single_escape=0; curpos=oldcurpos; } break; case V('b','r'): if (still_dd) out_html("<DD>"); else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) { c=scan_escape(c+1); } c=skip_till_newline(c);break; case V('c','2'): c=c+j; if (*c!='\n') { nobreaksym=*c; } else nobreaksym='\''; c=skip_till_newline(c); break; case V('c','c'): c=c+j; if (*c!='\n') { controlsym=*c; } else controlsym='.'; c=skip_till_newline(c); break; case V('c','e'): c=c+j; if (*c=='\n') { i=1; } else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && strncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; case V('e','c'): c=c+j; if (*c!='\n') { escapesym=*c; } else escapesym='\\'; break; c=skip_till_newline(c); case V('e','o'): escapesym='\0'; c=skip_till_newline(c); break; case V('e','x'): return 0; break; case V('f','c'): c=c+j; if (*c=='\n') { fieldsym=padsym='\0'; } else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; case V('f','i'): if (!fillout) { out_html(change_to_font(0)); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; case V('f','t'): c=c+j; if (*c=='\n') { out_html(change_to_font(0)); } else { if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(change_to_font(fn)); } else { out_html(change_to_font(*c)); c++; } } c=skip_till_newline(c); break; case V('e','l'): { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case V('i','e'): /* .ie c anything : then part of if else */ case V('i','f'): { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); int ifelseval=!i; s_ifelseval.push( ifelseval ); if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case V('i','g'): { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && strncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case V('n','f'): if (fillout) { out_html(change_to_font(0)); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; case V('p','s'): c=c+j; if (*c=='\n') { out_html(change_to_size('0')); } else { j=0;i=0; if (*c=='-') { j= -1;c++; } else if (*c=='+') { j=1;c++;} c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; case V('s','p'): c=c+j; if (fillout) out_html("<P>"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; case V('s','o'): { /* FILE *f; */ char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') { h=c; } else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { fprintf(stderr, "man2html: unable to open or read file %s.\n", h); out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else { scan_troff(buf+1,0,NULL); } if (buf) delete [] buf; if (name) delete [] name; *c++='\n'; break; } case V('t','a'): c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; case V('t','i'): /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; case V('t','m'): c=c+j; h=c; while (*c!='\n') c++; *c='\0'; /* fprintf(stderr,"%s\n", h); */ *c='\n'; break; case V('B',' '): case V('B','\n'): case V('I',' '): case V('I','\n'): /* parse one line in a certain font */ out_html(change_to_font(*c)); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('F','d'): //for "Function definitions", mdoc package case V('F','n'): //for "Function calls": brackets and commas have to be inserted automatically case V('F','o'): case V('F','c'): { bool inFdMode=(c[1]=='d'); char font[2] ; font[0] = 'B'; font[1] = 'B'; c=c+j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words); c=sl+1; /* .BR name (section) ** indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(change_to_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (inFdMode) continue; if (i==0) { out_html(" ("); if (!mandoc_synopsis) out_html(") "); } else if (i<words-1) out_html(", "); } if (mandoc_synopsis) { if (!inFdMode) out_html(");"); out_html("<br>"); }; out_html(change_to_font('R')); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; }; break; case V('O','P'): /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=1; c[0]='B'; c[1]='I'; out_html(change_to_font('R')); out_html("["); curpos++; case V('F','t'): //perhaps "Function return type" case V('F','a'): //"Function argument" case V('B','R'): case V('B','I'): case V('I','B'): case V('I','R'): case V('R','B'): case V('R','I'): { bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words); c=sl+1; /* .BR name (section) ** indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(change_to_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(change_to_font('R')); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; } break; case V('D','T'): for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; case V('I','P'): sl=fill_words(c+j, wordlist, &words); c=sl+1; if (!dl_set[itemdepth]) { out_html("<DL COMPACT>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) { scan_troff(wordlist[0], 1,NULL); } out_html("<DD>"); curpos=0; break; case V('T','P'): if (!dl_set[itemdepth]) { out_html("<P><DL COMPACT>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=1; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; case V('I','X'): /* general index */ c=skip_till_newline(c); break; case V('P',' '): case V('P','\n'): case V('L','P'): case V('P','P'): if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<P>\n"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; case V('H','P'): if (!dl_set[itemdepth]) { out_html("<DL COMPACT>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=1; c=skip_till_newline(c); curpos=0; break; case V('P','D'): c=skip_till_newline(c); break; case V('R','s'): /* BSD mandoc */ case V('R','S'): sl=fill_words(c+j, wordlist, &words); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL COMPACT><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } case V('R','e'): /* BSD mandoc */ case V('R','E'): if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; case V('S','B'): out_html(change_to_size(-1)); out_html(change_to_font('B')); c=scan_troff(c+j, 1, NULL); out_html(change_to_font('R')); out_html(change_to_size('0')); break; case V('S','M'): c=c+j; if (*c=='\n') c++; out_html(change_to_size(-1)); trans_char(c,'"','\a'); c=scan_troff(c,1,NULL); out_html(change_to_size('0')); break; case V('S','s'): /* BSD mandoc */ mandoc_command = 1; case V('S','S'): mode=1; case V('S','h'): /* BSD mandoc */ /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case V('S','H'): c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(change_to_font(0)); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); /* &nbsp; for mosaic users */ if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = strncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; case V('S','x'): // reference to a section header out_html(change_to_font('B')); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('T','S'): c=scan_table(c); break; case V('D','t'): /* BSD mandoc */ mandoc_command = 1; case V('T','H'): if (!output_possible) { sl = fill_words(c+j, wordlist, &words); if (words>1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; output_possible=1; out_html( DOCTYPE"<HTML><HEAD><TITLE>Manpage of "); out_html( wordlist[0]); out_html( "</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\"KDE_COMMON_DIR/kde-default.css\" type=\"text/css\">\n" ); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div id=\"headline\" style=\"position : absolute; height : 85px; z-index :\n" ); out_html("100; background : transparent; text-align : center; text-transform:\n" ); out_html("smallcaps; width : 100%; top : 0px; left : 0px; width : 100%; color :\n" ); out_html("#000000;\">\n" ); out_html("\n" ); out_html("<H1>" ); out_html( wordlist[0] ); out_html("</H1>\n" ); out_html("</div>\n" ); out_html("<div id=\"navbackground\" style=\"position : absolute; width : 100%; height\n" ); out_html(": 124px; background-image : url('KDE_COMMON_DIR/doctop2.png'); z-index : 5; left\n" ); out_html(": 0px; top : 0px; padding : 0px;\"> <div id=\"bulb1\" style=\"padding : 0px;\n" ); out_html("position : absolute; z-index : 15; width : 150px; height : 85px; top :\n" ); out_html("0px; left : 0px; background : url('KDE_COMMON_DIR/doctop1.png') repeat;\"></div>\n" ); out_html("<div id=\"gradient\" style=\"position : absolute; width : 275px; height :\n" ); out_html("85px; z-index : 19px; top : 0px; padding : 0px; left : 150px;\n" ); out_html("background-image : url('KDE_COMMON_DIR/doctop1a.png'); background-repeat :\n" ); out_html("no-repeat; background-color : transparent; visibility : visible;\"></div>\n" ); out_html("\n" ); out_html("<div id=\"bulb-bit\" style=\"position : absolute; width : 100%; height :\n" ); out_html("25px; top : 85px; left : 0px; background-image :\n" ); out_html("url('KDE_COMMON_DIR/doctop1b.png'); background-repeat : no-repeat;\n" ); out_html("background-color : transparent; z-index : 5;\"></div></div>\n" ); out_html("<h1>" ); out_html( wordlist[0] ); out_html( "</h1>\n" ); out_html("\n" ); out_html("Section: " ); if (words>4) out_html(wordlist[4]); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(wordlist[1]); out_html(")\n"); *sl='\n'; if (mandoc_command) out_html("<BR>BSD mandoc<BR>"); } c=sl+1; } else c=skip_till_newline(c); curpos=0; break; case V('T','X'): { sl=fill_words(c+j, wordlist, &words); *sl='\0'; out_html(change_to_font('I')); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=strlen(c2); out_html(c2); out_html(change_to_font('R')); if (words>1) out_html(wordlist[1]); *sl='\n'; c=sl+1; } break; case V('r','m'): /* .rm xx : Remove request, macro or string */ case V('r','n'): /* .rn xx yy : Rename request, macro or string xx to yy */ { STRDEF *de; c=c+j; i=V(c[0],c[1]); c=c+2; while (isspace(*c) && *c!='\n') c++; j=V(c[0],c[1]); while (*c && *c!='\n') c++; c++; de=strdef; while (de && de->nr!=j) de=de->next; if (de) { delete [] de->st; de->st=0; de->nr=0; } de=strdef; while (de && de->nr!=i) de=de->next; if (de) de->nr=j; break; } case V('n','x'): /* .nx filename : next file. */ case V('i','n'): /* .in +-N : Indent */ c=skip_till_newline(c); break; case V('n','r'): /* .nr R +-N M: define and set number register R by +-N; ** auto-increment by M */ { INTDEF *intd; c=c+j; i=V(c[0],c[1]); c=c+2; intd=intdef; while (intd && intd->nr!=i) intd=intd->next; if (!intd) { intd = new INTDEF(); intd->nr=i; intd->val=0; intd->incr=0; intd->next=intdef; intdef=intd; } while (*c==' ' || *c=='\t') c++; c=scan_expression(c,&intd->val); if (*c!='\n') { while (*c==' ' || *c=='\t') c++; c=scan_expression(c,&intd->incr); } c=skip_till_newline(c); break; } case V('a','m'): /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=1; case V('d','e'): /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { STRDEF *de; int olen=0; char c2; c=c+j; sl=fill_words(c, wordlist, &words); c2 = c[1]; if (c2 == '\n') c2 = ' '; i=V(c[0],c2);j=2; if (words==1) { wordlist[1] = qstrdup(".."); } else { wordlist[1]--; wordlist[1][0]='.'; j=3; } c=sl+1; sl=c; while (*c && strncmp(c,wordlist[1],j)) c=skip_till_newline(c); de=defdef; while (de && de->nr!= i) de=de->next; if (mode && de) olen=strlen(de->st); j=olen+c-sl; h = stralloc(j*2+4); if (h) { for (j=0; j<olen; j++) h[j]=de->st[j]; if (!j || h[j-1]!='\n') h[j++]='\n'; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { h[j++]='\\'; sl++; } else h[j++]=*sl; sl++; } h[j]=0; if (de) { delete [] de->st; de->st=h; } else { de = new STRDEF(); de->nr=i; de->next=defdef; de->st=h; defdef=de; } } if (words==1) { delete [] wordlist[1]; } } c=skip_till_newline(c); break; case V('B','l'): /* BSD mandoc */ { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) { /* These things can nest. */ itemdepth++; } if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL COMPACT>\n"); } if (fillout) out_html("<P>\n"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; } case V('E','l'): /* BSD mandoc */ c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("</DL>\n"); } else if (dl_set[itemdepth] & BL_BULLET_LIST) { out_html("</UL>\n"); } else if (dl_set[itemdepth] & BL_ENUM_LIST) { out_html("</OL>\n"); } dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<P>\n"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; case V('I','t'): /* BSD mandoc */ c=c+j; if (strncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) { c = skip_till_newline(c); } if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(change_to_font('B')); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(change_to_font('R')); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; case V('B','k'): /* BSD mandoc */ case V('E','k'): /* BSD mandoc */ case V('D','d'): /* BSD mandoc */ case V('O','s'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('B','t'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; case V('A','t'): /* BSD mandoc */ case V('F','x'): /* BSD mandoc */ case V('N','x'): /* BSD mandoc */ case V('O','x'): /* BSD mandoc */ case V('B','x'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (i==V('A','t')) out_html("AT&amp;T Unix "); else if (i==V('F','x')) out_html("FreeBSD "); else if (i==V('N','x')) out_html("NetBSD "); else if (i==V('O','x')) out_html("OpenBSD "); else if (i==V('B','x')) out_html("BSD "); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; case V('D','l'): /* BSD mandoc */ c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); out_html(change_to_font('L')); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; case V('B','d'): /* BSD mandoc */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) { strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); } out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(change_to_font(0)); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case V('E','d'): /* BSD mandoc */ if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(change_to_font(0)); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; case V('B','e'): /* BSD mandoc */ c=c+j; if (fillout) out_html("<P>"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; case V('X','r'): /* BSD mandoc */ { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } break; case V('F','l'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; out_html("-"); if (*c!='\n') { out_html(change_to_font('B')); c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); } out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('P','a'): /* BSD mandoc */ case V('P','f'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('P','p'): /* BSD mandoc */ if (fillout) out_html("<P>\n"); else { out_html(NEWLINE); NEWLINE[0]='\n'; } curpos=0; c=skip_till_newline(c); break; case V('D','q'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html("``"); c=scan_troff_mandoc(c, 1, NULL); out_html("''"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('O','p'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(change_to_font('R')); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('O','o'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(change_to_font('R')); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; case V('O','c'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html("]"); if (fillout) curpos++; else curpos=0; break; case V('P','q'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html("("); c=scan_troff_mandoc(c, 1, NULL); out_html(")"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('Q','l'): /* BSD mandoc */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case V('S','q'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html("`"); c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('A','r'): /* BSD mandoc */ /* parse one line in italics */ out_html(change_to_font('I')); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else { c=scan_troff_mandoc(c, 1, NULL); } out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('A','d'): /* BSD mandoc */ case V('E','m'): /* BSD mandoc */ case V('V','a'): /* BSD mandoc */ case V('X','c'): /* BSD mandoc */ /* parse one line in italics */ out_html(change_to_font('I')); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('N','d'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('N','m'): /* BSD mandoc */ { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ static int count = 0; /* Don't break on the first Nm */ if (count) { out_html("<BR>"); } else { char *end = strchr(c, '\n'); if (end) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, end - c, SMALL_STR_MAX); } } count++; } out_html(change_to_font('B')); while (*c == ' '|| *c == '\t') c++; if (*c == '\n') { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); } else { c=scan_troff_mandoc(c, 1, NULL); } out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case V('C','d'): /* BSD mandoc */ case V('C','m'): /* BSD mandoc */ case V('I','c'): /* BSD mandoc */ case V('M','s'): /* BSD mandoc */ case V('O','r'): /* BSD mandoc */ case V('S','y'): /* BSD mandoc */ /* parse one line in bold */ out_html(change_to_font('B')); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('D','v'): /* BSD mandoc */ case V('E','v'): /* BSD mandoc */ case V('F','r'): /* BSD mandoc */ case V('L','i'): /* BSD mandoc */ case V('N','o'): /* BSD mandoc */ case V('N','s'): /* BSD mandoc */ case V('T','n'): /* BSD mandoc */ case V('n','N'): /* BSD mandoc */ trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(change_to_font('B')); c=scan_troff_mandoc(c, 1, NULL); out_html(change_to_font('R')); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; case V('%','A'): /* BSD mandoc biblio stuff */ case V('%','D'): case V('%','N'): case V('%','O'): case V('%','P'): case V('%','Q'): case V('%','V'): c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; case V('%','B'): case V('%','J'): case V('%','R'): case V('%','T'): c=c+j; out_html(change_to_font('I')); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(change_to_font('R')); if (fillout) curpos++; else curpos=0; break; default: /* search macro database of self-defined macros */ owndef = defdef; while (owndef && owndef->nr!=i) owndef=owndef->next; if (owndef) { char **oldargument; int deflen; int onff; sl=fill_words(c+j, wordlist, &words); c=sl+1; *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) { scan_troff_mandoc(wordlist[i],1,&h); } else { scan_troff(wordlist[i],1,&h); } wordlist[i] = qstrdup(h); delete [] h; } for (i=words;i<20; i++) wordlist[i]=NULL; deflen = strlen(owndef->st); for (i=0; (owndef->st[deflen+2+i]=owndef->st[i]); i++); oldargument=argument; argument=wordlist; onff=newline_for_fun; if (mandoc_command) { scan_troff_mandoc(owndef->st+deflen+2, 0, NULL); } else { scan_troff(owndef->st+deflen+2, 0, NULL); } newline_for_fun=onff; argument=oldargument; for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; } else if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any BSD mandoc commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; strncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(change_to_font('R')); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else { c=skip_till_newline(c); } break; } } if (fillout) { out_html(NEWLINE); curpos++; } NEWLINE[0]='\n'; return c;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/473c0f88b96ea5413b7fed18dcacb7820b4d4134/man2html.cpp/buggy/kioslave/man/man2html.cpp
QString signalName() const { return m_signalName; };
virtual QString signalName() const { return m_signalName; };
QString signalName() const { return m_signalName; };
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/612dc0026206300c21fba1aa7c7f0071ba588598/krashconf.h/buggy/drkonqi/krashconf.h
int signalNumber() const { return m_signalnum; };
virtual int signalNumber() const { return m_signalnum; };
int signalNumber() const { return m_signalnum; };
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/612dc0026206300c21fba1aa7c7f0071ba588598/krashconf.h/buggy/drkonqi/krashconf.h
VG_(debugLog)(1, "syswrap-x86-netbsd", "entering VG_(main_thread_wrapper_NORETURN)\n");
VG_(printf)( "syswrap-x86-netbsd entering VG_(main_thread_wrapper_NORETURN)\n");
void VG_(main_thread_wrapper_NORETURN)(ThreadId tid){ VG_(debugLog)(1, "syswrap-x86-netbsd", "entering VG_(main_thread_wrapper_NORETURN)\n"); UWord* esp = allocstack(tid); /* shouldn't be any other threads around yet */ vg_assert( VG_(count_living_threads)() == 1 ); call_on_new_stack_0_1( (Addr)esp, /* stack */ 0, /*bogus return address*/ run_a_thread_NORETURN, /* fn to call */ (Word)tid /* arg to give it */ ); /*NOTREACHED*/ vg_assert(0);}
12192 /local/tlutelli/issta_data/temp/c/2005_temp/2005/12192/315c1dc865ec1c77ccf4763170f3acfe24b3ef37/syswrap-x86-netbsdelf2.c/buggy/branches/aspacem/valgrind/coregrind/m_syswrap/syswrap-x86-netbsdelf2.c
VG_(printf)("calling call on new_stack\n");
void VG_(main_thread_wrapper_NORETURN)(ThreadId tid){ VG_(debugLog)(1, "syswrap-x86-netbsd", "entering VG_(main_thread_wrapper_NORETURN)\n"); UWord* esp = allocstack(tid); /* shouldn't be any other threads around yet */ vg_assert( VG_(count_living_threads)() == 1 ); call_on_new_stack_0_1( (Addr)esp, /* stack */ 0, /*bogus return address*/ run_a_thread_NORETURN, /* fn to call */ (Word)tid /* arg to give it */ ); /*NOTREACHED*/ vg_assert(0);}
12192 /local/tlutelli/issta_data/temp/c/2005_temp/2005/12192/315c1dc865ec1c77ccf4763170f3acfe24b3ef37/syswrap-x86-netbsdelf2.c/buggy/branches/aspacem/valgrind/coregrind/m_syswrap/syswrap-x86-netbsdelf2.c
qDebug( "[%s] ", (*i) );
qDebug( "[%s] ", (const char*)(*i).utf8() );
virtual void dump( ) const { if ( QVariant::StringList == value_.type() ) { QStringList sl = value_.toStringList(); for ( QStringList::const_iterator i = sl.begin(); i != sl.end(); ++i ) { qDebug( "[%s] ", (*i) ); } } else { qDebug( "%s", value_.toString() ); } }
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/67f279f0227b40aec9d7c21507f474002767db3c/qgsproject.cpp/clean/src/qgsproject.cpp
qDebug( "%s", value_.toString() );
qDebug( "%s", (const char*)value_.toString().utf8() );
virtual void dump( ) const { if ( QVariant::StringList == value_.type() ) { QStringList sl = value_.toStringList(); for ( QStringList::const_iterator i = sl.begin(); i != sl.end(); ++i ) { qDebug( "[%s] ", (*i) ); } } else { qDebug( "%s", value_.toString() ); } }
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/67f279f0227b40aec9d7c21507f474002767db3c/qgsproject.cpp/clean/src/qgsproject.cpp
WNDCLASSFc.lpszMenuName = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpszMenuName", "I"); WNDCLASSFc.hbrBackground = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hbrBackground", "I"); WNDCLASSFc.hCursor = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hCursor", "I"); WNDCLASSFc.hIcon = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hIcon", "I"); WNDCLASSFc.hInstance = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hInstance", "I"); WNDCLASSFc.cbWndExtra = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "cbWndExtra", "I"); WNDCLASSFc.cbClsExtra = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "cbClsExtra", "I"); WNDCLASSFc.lpfnWndProc = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpfnWndProc", "I"); WNDCLASSFc.style = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "style", "I");
void cacheWNDCLASSFields(JNIEnv *env, jobject lpObject){ if (WNDCLASSFc.cached) return; WNDCLASSFc.clazz = (*env)->GetObjectClass(env, lpObject); WNDCLASSFc.lpszClassName = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpszClassName", "I"); WNDCLASSFc.lpszMenuName = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpszMenuName", "I"); WNDCLASSFc.hbrBackground = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hbrBackground", "I"); WNDCLASSFc.hCursor = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hCursor", "I"); WNDCLASSFc.hIcon = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hIcon", "I"); WNDCLASSFc.hInstance = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "hInstance", "I"); WNDCLASSFc.cbWndExtra = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "cbWndExtra", "I"); WNDCLASSFc.cbClsExtra = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "cbClsExtra", "I"); WNDCLASSFc.lpfnWndProc = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "lpfnWndProc", "I"); WNDCLASSFc.style = (*env)->GetFieldID(env, WNDCLASSFc.clazz, "style", "I"); WNDCLASSFc.cached = 1;}
11867 /local/tlutelli/issta_data/temp/c/2005_temp/2005/11867/87f953c8eda7bc7ceddf6227acc0065974196814/structs.c/buggy/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
int read = f.readLine( buf.data(), buf.size() );
int read = f.readBlock( buf.data(), buf.size() );
static void copyFile(QFile& tmp, QString const& filename, bool ){ QFile f( filename ); if ( f.open(IO_ReadOnly) ) { QCString buf( 8192 ); while ( !f.atEnd() ) { int read = f.readLine( buf.data(), buf.size() ); if ( read > 0 ) tmp.writeBlock( buf.data(), read ); } }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/b079b15c4952423dbe79b3b6263d0cf9cc0a9eea/krdb.cpp/clean/kcontrol/krdb/krdb.cpp
KHMainWindow *mw = new KHMainWindow(url);
MainWindow *mw = new MainWindow(url);
extern "C" int kdemain(int argc, char *argv[]){ KAboutData aboutData( "khelpcenter", I18N_NOOP("KDE HelpCenter"), HELPCENTER_VERSION, I18N_NOOP("The KDE Help Center"), KAboutData::License_GPL, "(c) 1999-2000, Matthias Elter"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); KApplication::addCmdLineOptions(); KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KURL url; if (args->count()) url = args->url(0); KHMainWindow *mw = new KHMainWindow(url); mw->show(); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a6448ad6a275d45f4b684d9087ea19700f85a4ac/mainwindow.cpp/clean/khelpcenter/mainwindow.cpp
ref++;
return ++ref;
int get() { assert(ref >= 0); if (ref == 0) lru_pin(); ref++; }
2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/8c7283a709cbd1031e4adc5c129a44d81b7a0f8d/Buffercache.h/buggy/ceph/client/Buffercache.h
t << "# Themes/Styles in the control center and disable the checkbox " << endl;
t << "# Look and Feel/Styles in the control center and disable the checkbox " << endl;
static void createGtkrc( bool exportColors, const QColorGroup& cg ){ QCString filename = ::getenv("HOME"); filename += "/.gtkrc-kde"; QFile f( filename ); if ( f.open( IO_WriteOnly) ) { QTextStream t( &f ); t.setEncoding( QTextStream::Latin1 ); t << "# created by KDE, " << QDateTime::currentDateTime().toString() << endl; t << "#" << endl; t << "# If you do not want KDE to override your GTK settings, select" << endl; t << "# Themes/Styles in the control center and disable the checkbox " << endl; t << "# \"Apply fonts and colors to non-KDE apps\"" << endl; t << "#" << endl; t << endl; t << "style \"default\"" << endl; t << "{" << endl; if (exportColors) { t << " bg[NORMAL] = " << color( cg.background() ) << endl; t << " bg[SELECTED] = " << color( cg.highlight() ) << endl; t << " bg[INSENSITIVE] = " << color( cg.background() ) << endl; t << " bg[ACTIVE] = " << color( cg.mid() ) << endl; t << " bg[PRELIGHT] = " << color( cg.background() ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.base() ) << endl; t << " base[SELECTED] = " << color( cg.highlight() ) << endl; t << " base[INSENSITIVE] = " << color( cg.background() ) << endl; t << " base[ACTIVE] = " << color( cg.base() ) << endl; t << " base[PRELIGHT] = " << color( cg.base() ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.text() ) << endl; t << " text[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " text[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " text[ACTIVE] = " << color( cg.text() ) << endl; t << " text[PRELIGHT] = " << color( cg.text() ) << endl; t << endl; t << " fg[NORMAL] = " << color( cg.foreground() ) << endl; t << " fg[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " fg[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " fg[ACTIVE] = " << color( cg.foreground() ) << endl; t << " fg[PRELIGHT] = " << color( cg.foreground() ) << endl; } t << "}" << endl; t << endl; t << "class \"*\" style \"default\"" << endl; t << endl; }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/2c9608e865edec2d33f4df25e6353c329589ac8e/krdb.cpp/buggy/kcontrol/krdb/krdb.cpp
error("Exiting on signal %d", sig);
fprintf(stderr, "Exiting on signal %d\n", sig);
void signal_exit(int sig){ error("Exiting on signal %d", sig); exit(1);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/clean/kdesu/kdesud/kdesud.cpp
QFile f( locateLocal("config", "gtkrc" ) );
KSaveFile saveFile( locateLocal( "config", "gtkrc" ) ); if ( saveFile.status() != 0 || saveFile.textStream() == 0L ) return;
static void createGtkrc( bool exportColors, const QColorGroup& cg ){ QFile f( locateLocal("config", "gtkrc" ) ); // lukas: why does it create in ~/.kde/share/config ??? if ( f.open( IO_WriteOnly) ) { QTextStream t( &f ); t.setEncoding( QTextStream::Locale ); t << i18n( "# created by KDE, %1\n" "#\n" "# If you do not want KDE to override your GTK settings, select\n" "# Appearance & Themes -> Colors in the Control Center and disable the checkbox\n" "# \"Apply colors to non-KDE applications\"\n" "#\n" "#\n").arg(QDateTime::currentDateTime().toString()).local8Bit(); t << "style \"default\"" << endl; t << "{" << endl; if (exportColors) { t << " bg[NORMAL] = " << color( cg.background() ) << endl; t << " bg[SELECTED] = " << color( cg.highlight() ) << endl; t << " bg[INSENSITIVE] = " << color( cg.background() ) << endl; t << " bg[ACTIVE] = " << color( cg.mid() ) << endl; t << " bg[PRELIGHT] = " << color( cg.background() ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.base() ) << endl; t << " base[SELECTED] = " << color( cg.highlight() ) << endl; t << " base[INSENSITIVE] = " << color( cg.background() ) << endl; t << " base[ACTIVE] = " << color( cg.base() ) << endl; t << " base[PRELIGHT] = " << color( cg.base() ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.text() ) << endl; t << " text[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " text[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " text[ACTIVE] = " << color( cg.text() ) << endl; t << " text[PRELIGHT] = " << color( cg.text() ) << endl; t << endl; t << " fg[NORMAL] = " << color( cg.foreground() ) << endl; t << " fg[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " fg[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " fg[ACTIVE] = " << color( cg.foreground() ) << endl; t << " fg[PRELIGHT] = " << color( cg.foreground() ) << endl; } t << "}" << endl; t << endl; t << "class \"*\" style \"default\"" << endl; t << endl; }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/ca9e9d446db753ee3030955a149f6464dd921769/krdb.cpp/clean/kcontrol/krdb/krdb.cpp
if ( f.open( IO_WriteOnly) ) { QTextStream t( &f ); t.setEncoding( QTextStream::Locale );
QTextStream& t = *saveFile.textStream(); t.setEncoding( QTextStream::Locale );
static void createGtkrc( bool exportColors, const QColorGroup& cg ){ QFile f( locateLocal("config", "gtkrc" ) ); // lukas: why does it create in ~/.kde/share/config ??? if ( f.open( IO_WriteOnly) ) { QTextStream t( &f ); t.setEncoding( QTextStream::Locale ); t << i18n( "# created by KDE, %1\n" "#\n" "# If you do not want KDE to override your GTK settings, select\n" "# Appearance & Themes -> Colors in the Control Center and disable the checkbox\n" "# \"Apply colors to non-KDE applications\"\n" "#\n" "#\n").arg(QDateTime::currentDateTime().toString()).local8Bit(); t << "style \"default\"" << endl; t << "{" << endl; if (exportColors) { t << " bg[NORMAL] = " << color( cg.background() ) << endl; t << " bg[SELECTED] = " << color( cg.highlight() ) << endl; t << " bg[INSENSITIVE] = " << color( cg.background() ) << endl; t << " bg[ACTIVE] = " << color( cg.mid() ) << endl; t << " bg[PRELIGHT] = " << color( cg.background() ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.base() ) << endl; t << " base[SELECTED] = " << color( cg.highlight() ) << endl; t << " base[INSENSITIVE] = " << color( cg.background() ) << endl; t << " base[ACTIVE] = " << color( cg.base() ) << endl; t << " base[PRELIGHT] = " << color( cg.base() ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.text() ) << endl; t << " text[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " text[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " text[ACTIVE] = " << color( cg.text() ) << endl; t << " text[PRELIGHT] = " << color( cg.text() ) << endl; t << endl; t << " fg[NORMAL] = " << color( cg.foreground() ) << endl; t << " fg[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " fg[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " fg[ACTIVE] = " << color( cg.foreground() ) << endl; t << " fg[PRELIGHT] = " << color( cg.foreground() ) << endl; } t << "}" << endl; t << endl; t << "class \"*\" style \"default\"" << endl; t << endl; }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/ca9e9d446db753ee3030955a149f6464dd921769/krdb.cpp/clean/kcontrol/krdb/krdb.cpp
t << i18n(
t << i18n(
static void createGtkrc( bool exportColors, const QColorGroup& cg ){ QFile f( locateLocal("config", "gtkrc" ) ); // lukas: why does it create in ~/.kde/share/config ??? if ( f.open( IO_WriteOnly) ) { QTextStream t( &f ); t.setEncoding( QTextStream::Locale ); t << i18n( "# created by KDE, %1\n" "#\n" "# If you do not want KDE to override your GTK settings, select\n" "# Appearance & Themes -> Colors in the Control Center and disable the checkbox\n" "# \"Apply colors to non-KDE applications\"\n" "#\n" "#\n").arg(QDateTime::currentDateTime().toString()).local8Bit(); t << "style \"default\"" << endl; t << "{" << endl; if (exportColors) { t << " bg[NORMAL] = " << color( cg.background() ) << endl; t << " bg[SELECTED] = " << color( cg.highlight() ) << endl; t << " bg[INSENSITIVE] = " << color( cg.background() ) << endl; t << " bg[ACTIVE] = " << color( cg.mid() ) << endl; t << " bg[PRELIGHT] = " << color( cg.background() ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.base() ) << endl; t << " base[SELECTED] = " << color( cg.highlight() ) << endl; t << " base[INSENSITIVE] = " << color( cg.background() ) << endl; t << " base[ACTIVE] = " << color( cg.base() ) << endl; t << " base[PRELIGHT] = " << color( cg.base() ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.text() ) << endl; t << " text[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " text[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " text[ACTIVE] = " << color( cg.text() ) << endl; t << " text[PRELIGHT] = " << color( cg.text() ) << endl; t << endl; t << " fg[NORMAL] = " << color( cg.foreground() ) << endl; t << " fg[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " fg[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " fg[ACTIVE] = " << color( cg.foreground() ) << endl; t << " fg[PRELIGHT] = " << color( cg.foreground() ) << endl; } t << "}" << endl; t << endl; t << "class \"*\" style \"default\"" << endl; t << endl; }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/ca9e9d446db753ee3030955a149f6464dd921769/krdb.cpp/clean/kcontrol/krdb/krdb.cpp
"#\n").arg(QDateTime::currentDateTime().toString()).local8Bit();
"#\n").arg(QDateTime::currentDateTime().toString());
static void createGtkrc( bool exportColors, const QColorGroup& cg ){ QFile f( locateLocal("config", "gtkrc" ) ); // lukas: why does it create in ~/.kde/share/config ??? if ( f.open( IO_WriteOnly) ) { QTextStream t( &f ); t.setEncoding( QTextStream::Locale ); t << i18n( "# created by KDE, %1\n" "#\n" "# If you do not want KDE to override your GTK settings, select\n" "# Appearance & Themes -> Colors in the Control Center and disable the checkbox\n" "# \"Apply colors to non-KDE applications\"\n" "#\n" "#\n").arg(QDateTime::currentDateTime().toString()).local8Bit(); t << "style \"default\"" << endl; t << "{" << endl; if (exportColors) { t << " bg[NORMAL] = " << color( cg.background() ) << endl; t << " bg[SELECTED] = " << color( cg.highlight() ) << endl; t << " bg[INSENSITIVE] = " << color( cg.background() ) << endl; t << " bg[ACTIVE] = " << color( cg.mid() ) << endl; t << " bg[PRELIGHT] = " << color( cg.background() ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.base() ) << endl; t << " base[SELECTED] = " << color( cg.highlight() ) << endl; t << " base[INSENSITIVE] = " << color( cg.background() ) << endl; t << " base[ACTIVE] = " << color( cg.base() ) << endl; t << " base[PRELIGHT] = " << color( cg.base() ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.text() ) << endl; t << " text[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " text[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " text[ACTIVE] = " << color( cg.text() ) << endl; t << " text[PRELIGHT] = " << color( cg.text() ) << endl; t << endl; t << " fg[NORMAL] = " << color( cg.foreground() ) << endl; t << " fg[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " fg[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " fg[ACTIVE] = " << color( cg.foreground() ) << endl; t << " fg[PRELIGHT] = " << color( cg.foreground() ) << endl; } t << "}" << endl; t << endl; t << "class \"*\" style \"default\"" << endl; t << endl; }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/ca9e9d446db753ee3030955a149f6464dd921769/krdb.cpp/clean/kcontrol/krdb/krdb.cpp
t << "style \"default\"" << endl;
t << "style \"default\"" << endl; t << "{" << endl; if (exportColors) { t << " bg[NORMAL] = " << color( cg.background() ) << endl; t << " bg[SELECTED] = " << color( cg.highlight() ) << endl; t << " bg[INSENSITIVE] = " << color( cg.background() ) << endl; t << " bg[ACTIVE] = " << color( cg.mid() ) << endl; t << " bg[PRELIGHT] = " << color( cg.background() ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.base() ) << endl; t << " base[SELECTED] = " << color( cg.highlight() ) << endl; t << " base[INSENSITIVE] = " << color( cg.background() ) << endl; t << " base[ACTIVE] = " << color( cg.base() ) << endl; t << " base[PRELIGHT] = " << color( cg.base() ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.text() ) << endl; t << " text[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " text[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " text[ACTIVE] = " << color( cg.text() ) << endl; t << " text[PRELIGHT] = " << color( cg.text() ) << endl; t << endl; t << " fg[NORMAL] = " << color( cg.foreground() ) << endl; t << " fg[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " fg[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " fg[ACTIVE] = " << color( cg.foreground() ) << endl; t << " fg[PRELIGHT] = " << color( cg.foreground() ) << endl; }
static void createGtkrc( bool exportColors, const QColorGroup& cg ){ QFile f( locateLocal("config", "gtkrc" ) ); // lukas: why does it create in ~/.kde/share/config ??? if ( f.open( IO_WriteOnly) ) { QTextStream t( &f ); t.setEncoding( QTextStream::Locale ); t << i18n( "# created by KDE, %1\n" "#\n" "# If you do not want KDE to override your GTK settings, select\n" "# Appearance & Themes -> Colors in the Control Center and disable the checkbox\n" "# \"Apply colors to non-KDE applications\"\n" "#\n" "#\n").arg(QDateTime::currentDateTime().toString()).local8Bit(); t << "style \"default\"" << endl; t << "{" << endl; if (exportColors) { t << " bg[NORMAL] = " << color( cg.background() ) << endl; t << " bg[SELECTED] = " << color( cg.highlight() ) << endl; t << " bg[INSENSITIVE] = " << color( cg.background() ) << endl; t << " bg[ACTIVE] = " << color( cg.mid() ) << endl; t << " bg[PRELIGHT] = " << color( cg.background() ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.base() ) << endl; t << " base[SELECTED] = " << color( cg.highlight() ) << endl; t << " base[INSENSITIVE] = " << color( cg.background() ) << endl; t << " base[ACTIVE] = " << color( cg.base() ) << endl; t << " base[PRELIGHT] = " << color( cg.base() ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.text() ) << endl; t << " text[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " text[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " text[ACTIVE] = " << color( cg.text() ) << endl; t << " text[PRELIGHT] = " << color( cg.text() ) << endl; t << endl; t << " fg[NORMAL] = " << color( cg.foreground() ) << endl; t << " fg[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " fg[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " fg[ACTIVE] = " << color( cg.foreground() ) << endl; t << " fg[PRELIGHT] = " << color( cg.foreground() ) << endl; } t << "}" << endl; t << endl; t << "class \"*\" style \"default\"" << endl; t << endl; }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/ca9e9d446db753ee3030955a149f6464dd921769/krdb.cpp/clean/kcontrol/krdb/krdb.cpp
if (exportColors) { t << " bg[NORMAL] = " << color( cg.background() ) << endl; t << " bg[SELECTED] = " << color( cg.highlight() ) << endl; t << " bg[INSENSITIVE] = " << color( cg.background() ) << endl; t << " bg[ACTIVE] = " << color( cg.mid() ) << endl; t << " bg[PRELIGHT] = " << color( cg.background() ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.base() ) << endl; t << " base[SELECTED] = " << color( cg.highlight() ) << endl; t << " base[INSENSITIVE] = " << color( cg.background() ) << endl; t << " base[ACTIVE] = " << color( cg.base() ) << endl; t << " base[PRELIGHT] = " << color( cg.base() ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.text() ) << endl; t << " text[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " text[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " text[ACTIVE] = " << color( cg.text() ) << endl; t << " text[PRELIGHT] = " << color( cg.text() ) << endl; t << endl; t << " fg[NORMAL] = " << color( cg.foreground() ) << endl; t << " fg[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " fg[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " fg[ACTIVE] = " << color( cg.foreground() ) << endl; t << " fg[PRELIGHT] = " << color( cg.foreground() ) << endl; }
QColorGroup group = QToolTip::palette().active(); t << " bg[NORMAL] = " << color( group.background() ) << endl; t << " base[NORMAL] = " << color( group.base() ) << endl; t << " text[NORMAL] = " << color( group.text() ) << endl; t << " fg[NORMAL] = " << color( group.foreground() ) << endl;
static void createGtkrc( bool exportColors, const QColorGroup& cg ){ QFile f( locateLocal("config", "gtkrc" ) ); // lukas: why does it create in ~/.kde/share/config ??? if ( f.open( IO_WriteOnly) ) { QTextStream t( &f ); t.setEncoding( QTextStream::Locale ); t << i18n( "# created by KDE, %1\n" "#\n" "# If you do not want KDE to override your GTK settings, select\n" "# Appearance & Themes -> Colors in the Control Center and disable the checkbox\n" "# \"Apply colors to non-KDE applications\"\n" "#\n" "#\n").arg(QDateTime::currentDateTime().toString()).local8Bit(); t << "style \"default\"" << endl; t << "{" << endl; if (exportColors) { t << " bg[NORMAL] = " << color( cg.background() ) << endl; t << " bg[SELECTED] = " << color( cg.highlight() ) << endl; t << " bg[INSENSITIVE] = " << color( cg.background() ) << endl; t << " bg[ACTIVE] = " << color( cg.mid() ) << endl; t << " bg[PRELIGHT] = " << color( cg.background() ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.base() ) << endl; t << " base[SELECTED] = " << color( cg.highlight() ) << endl; t << " base[INSENSITIVE] = " << color( cg.background() ) << endl; t << " base[ACTIVE] = " << color( cg.base() ) << endl; t << " base[PRELIGHT] = " << color( cg.base() ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.text() ) << endl; t << " text[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " text[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " text[ACTIVE] = " << color( cg.text() ) << endl; t << " text[PRELIGHT] = " << color( cg.text() ) << endl; t << endl; t << " fg[NORMAL] = " << color( cg.foreground() ) << endl; t << " fg[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " fg[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " fg[ACTIVE] = " << color( cg.foreground() ) << endl; t << " fg[PRELIGHT] = " << color( cg.foreground() ) << endl; } t << "}" << endl; t << endl; t << "class \"*\" style \"default\"" << endl; t << endl; }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/ca9e9d446db753ee3030955a149f6464dd921769/krdb.cpp/clean/kcontrol/krdb/krdb.cpp
t << "class \"*\" style \"default\"" << endl;
t << "widget \"gtk-tooltips\" style \"ToolTip\"" << endl; t << endl; t << "style \"MenuItem\"" << endl; t << "{" << endl; t << " bg[PRELIGHT] = " << color( cg.highlight() ) << endl; t << "}" << endl; t << endl; t << "class \"*MenuItem\" style \"MenuItem\"" << endl;
static void createGtkrc( bool exportColors, const QColorGroup& cg ){ QFile f( locateLocal("config", "gtkrc" ) ); // lukas: why does it create in ~/.kde/share/config ??? if ( f.open( IO_WriteOnly) ) { QTextStream t( &f ); t.setEncoding( QTextStream::Locale ); t << i18n( "# created by KDE, %1\n" "#\n" "# If you do not want KDE to override your GTK settings, select\n" "# Appearance & Themes -> Colors in the Control Center and disable the checkbox\n" "# \"Apply colors to non-KDE applications\"\n" "#\n" "#\n").arg(QDateTime::currentDateTime().toString()).local8Bit(); t << "style \"default\"" << endl; t << "{" << endl; if (exportColors) { t << " bg[NORMAL] = " << color( cg.background() ) << endl; t << " bg[SELECTED] = " << color( cg.highlight() ) << endl; t << " bg[INSENSITIVE] = " << color( cg.background() ) << endl; t << " bg[ACTIVE] = " << color( cg.mid() ) << endl; t << " bg[PRELIGHT] = " << color( cg.background() ) << endl; t << endl; t << " base[NORMAL] = " << color( cg.base() ) << endl; t << " base[SELECTED] = " << color( cg.highlight() ) << endl; t << " base[INSENSITIVE] = " << color( cg.background() ) << endl; t << " base[ACTIVE] = " << color( cg.base() ) << endl; t << " base[PRELIGHT] = " << color( cg.base() ) << endl; t << endl; t << " text[NORMAL] = " << color( cg.text() ) << endl; t << " text[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " text[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " text[ACTIVE] = " << color( cg.text() ) << endl; t << " text[PRELIGHT] = " << color( cg.text() ) << endl; t << endl; t << " fg[NORMAL] = " << color( cg.foreground() ) << endl; t << " fg[SELECTED] = " << color( cg.highlightedText() ) << endl; t << " fg[INSENSITIVE] = " << color( cg.mid() ) << endl; t << " fg[ACTIVE] = " << color( cg.foreground() ) << endl; t << " fg[PRELIGHT] = " << color( cg.foreground() ) << endl; } t << "}" << endl; t << endl; t << "class \"*\" style \"default\"" << endl; t << endl; }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/ca9e9d446db753ee3030955a149f6464dd921769/krdb.cpp/clean/kcontrol/krdb/krdb.cpp
if (cur == NULL) return(NULL); if (cur->type != XML_NAMESPACE_DECL) return(NULL); /* * One can add namespaces only on element nodes */ if ((node != NULL) && (node->type != XML_ELEMENT_NODE)) node = NULL;
xsltCopyNamespaceList(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNsPtr cur) { xmlNsPtr ret = NULL; xmlNsPtr p = NULL,q; const xmlChar *URI; while (cur != NULL) { if (!xmlStrEqual(cur->href, XSLT_NAMESPACE)) { /* TODO apply cascading */ URI = (const xmlChar *) xmlHashLookup(ctxt->style->nsAliases, cur->href); if (URI != NULL) { q = xmlNewNs(node, URI, cur->prefix); } else { q = xmlNewNs(node, cur->href, cur->prefix); } if (p == NULL) { ret = p = q; } else { p->next = q; p = q; } } cur = cur->next; } return(ret);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/fd8a7f1b51439bbcf01b819d7cc964127181d210/namespaces.c/buggy/kioslave/help/libxslt/namespaces.c
"xsltApplyStylesheet: insupported method xhtml, using html\n",
"xsltApplyStylesheet: unsupported method xhtml, using html\n",
xsltApplyStylesheet(xsltStylesheetPtr style, xmlDocPtr doc, const char **params) { xmlDocPtr res = NULL; xsltTransformContextPtr ctxt = NULL; xmlNodePtr root; const xmlChar *method; const xmlChar *doctypePublic; const xmlChar *doctypeSystem; const xmlChar *version; xsltStackElemPtr variables; xsltStackElemPtr vptr; if ((style == NULL) || (doc == NULL)) return(NULL); ctxt = xsltNewTransformContext(style, doc); xsltRegisterExtras(ctxt); if (ctxt == NULL) return(NULL); XSLT_GET_IMPORT_PTR(method, style, method) XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic) XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem) XSLT_GET_IMPORT_PTR(version, style, version) if ((method != NULL) && (!xmlStrEqual(method, (const xmlChar *) "xml"))) { if (xmlStrEqual(method, (const xmlChar *) "html")) { ctxt->type = XSLT_OUTPUT_HTML; if (((doctypePublic != NULL) || (doctypeSystem != NULL))) res = htmlNewDoc(doctypeSystem, doctypePublic); else { if (version == NULL) version = (const xmlChar *) "4.0";#ifdef XSLT_GENERATE_HTML_DOCTYPE xsltGetHTMLIDs(version, &doctypePublic, &doctypeSystem);#endif res = htmlNewDoc(doctypeSystem, doctypePublic); } if (res == NULL) goto error; } else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) { xsltGenericError(xsltGenericErrorContext, "xsltApplyStylesheet: insupported method xhtml, using html\n", style->method); ctxt->type = XSLT_OUTPUT_HTML; res = htmlNewDoc(doctypeSystem, doctypePublic); if (res == NULL) goto error; } else if (xmlStrEqual(style->method, (const xmlChar *) "text")) { ctxt->type = XSLT_OUTPUT_TEXT; res = xmlNewDoc(style->version); if (res == NULL) goto error; } else { xsltGenericError(xsltGenericErrorContext, "xsltApplyStylesheet: insupported method %s\n", style->method); goto error; } } else { ctxt->type = XSLT_OUTPUT_XML; res = xmlNewDoc(style->version); if (res == NULL) goto error; } res->charset = XML_CHAR_ENCODING_UTF8; if (style->encoding != NULL) res->encoding = xmlStrdup(style->encoding); variables = style->variables; /* * Start the evaluation, evaluate the params, the stylesheets globals * and start by processing the top node. */ ctxt->output = res; ctxt->insert = (xmlNodePtr) res; ctxt->globalVars = xmlHashCreate(20); if (params != NULL) xsltEvalUserParams(ctxt, params); xsltEvalGlobalVariables(ctxt); ctxt->node = (xmlNodePtr) doc; varsPush(ctxt, NULL); xsltProcessOneNode(ctxt, ctxt->node); xsltFreeStackElemList(varsPop(ctxt)); xsltCleanupTemplates(style); /* TODO: <- style should be read only */ /* * Now cleanup our variables so stylesheet can be re-used * * TODO: this is not needed anymore global variables are copied * and not evaluated directly anymore, keep this as a check */ if (style->variables != variables) { vptr = style->variables; while (vptr->next!=variables) vptr = vptr->next; vptr->next = NULL; xsltFreeStackElemList(style->variables); style->variables = variables; } vptr = style->variables; while(vptr!=NULL) { if (vptr->computed) { if (vptr->value != NULL) { xmlXPathFreeObject(vptr->value); vptr->value = NULL; vptr->computed = 0; } } vptr = vptr->next; } /* * Do some post processing work depending on the generated output */ root = xmlDocGetRootElement(res); if (root != NULL) { /* * Apply the default selection of the method */ if ((method == NULL) && (root->ns == NULL) && (!xmlStrcasecmp(root->name, (const xmlChar *) "html"))) { xmlNodePtr tmp; tmp = res->children; while ((tmp != NULL) && (tmp != root)) { if (tmp->type == XML_ELEMENT_NODE) break; if ((tmp->type == XML_TEXT_NODE) && (!xmlIsBlankNode(tmp))) break; } if (tmp == root) { ctxt->type = XSLT_OUTPUT_HTML; res->type = XML_HTML_DOCUMENT_NODE; if (((doctypePublic != NULL) || (doctypeSystem != NULL))) res->intSubset = xmlCreateIntSubset(res, root->name, doctypePublic, doctypeSystem);#ifdef XSLT_GENERATE_HTML_DOCTYPE else { if (version == NULL) version = (const xmlChar *) "4.0"; xsltGetHTMLIDs(version, &doctypePublic, &doctypeSystem); if (((doctypePublic != NULL) || (doctypeSystem != NULL))) res->intSubset = xmlCreateIntSubset(res, root->name, doctypePublic, doctypeSystem); }#endif } } if (ctxt->type == XSLT_OUTPUT_XML) { XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic) XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem) if (((doctypePublic != NULL) || (doctypeSystem != NULL))) res->intSubset = xmlCreateIntSubset(res, root->name, doctypePublic, doctypeSystem); } } xmlXPathFreeNodeSet(ctxt->nodeList); xsltFreeTransformContext(ctxt); return(res);error: if (res != NULL) xmlFreeDoc(res); if (ctxt != NULL) xsltFreeTransformContext(ctxt); return(NULL);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/fd8a7f1b51439bbcf01b819d7cc964127181d210/transform.c/clean/kioslave/help/libxslt/transform.c
"xsltApplyStylesheet: insupported method %s\n",
"xsltApplyStylesheet: unsupported method %s\n",
xsltApplyStylesheet(xsltStylesheetPtr style, xmlDocPtr doc, const char **params) { xmlDocPtr res = NULL; xsltTransformContextPtr ctxt = NULL; xmlNodePtr root; const xmlChar *method; const xmlChar *doctypePublic; const xmlChar *doctypeSystem; const xmlChar *version; xsltStackElemPtr variables; xsltStackElemPtr vptr; if ((style == NULL) || (doc == NULL)) return(NULL); ctxt = xsltNewTransformContext(style, doc); xsltRegisterExtras(ctxt); if (ctxt == NULL) return(NULL); XSLT_GET_IMPORT_PTR(method, style, method) XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic) XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem) XSLT_GET_IMPORT_PTR(version, style, version) if ((method != NULL) && (!xmlStrEqual(method, (const xmlChar *) "xml"))) { if (xmlStrEqual(method, (const xmlChar *) "html")) { ctxt->type = XSLT_OUTPUT_HTML; if (((doctypePublic != NULL) || (doctypeSystem != NULL))) res = htmlNewDoc(doctypeSystem, doctypePublic); else { if (version == NULL) version = (const xmlChar *) "4.0";#ifdef XSLT_GENERATE_HTML_DOCTYPE xsltGetHTMLIDs(version, &doctypePublic, &doctypeSystem);#endif res = htmlNewDoc(doctypeSystem, doctypePublic); } if (res == NULL) goto error; } else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) { xsltGenericError(xsltGenericErrorContext, "xsltApplyStylesheet: insupported method xhtml, using html\n", style->method); ctxt->type = XSLT_OUTPUT_HTML; res = htmlNewDoc(doctypeSystem, doctypePublic); if (res == NULL) goto error; } else if (xmlStrEqual(style->method, (const xmlChar *) "text")) { ctxt->type = XSLT_OUTPUT_TEXT; res = xmlNewDoc(style->version); if (res == NULL) goto error; } else { xsltGenericError(xsltGenericErrorContext, "xsltApplyStylesheet: insupported method %s\n", style->method); goto error; } } else { ctxt->type = XSLT_OUTPUT_XML; res = xmlNewDoc(style->version); if (res == NULL) goto error; } res->charset = XML_CHAR_ENCODING_UTF8; if (style->encoding != NULL) res->encoding = xmlStrdup(style->encoding); variables = style->variables; /* * Start the evaluation, evaluate the params, the stylesheets globals * and start by processing the top node. */ ctxt->output = res; ctxt->insert = (xmlNodePtr) res; ctxt->globalVars = xmlHashCreate(20); if (params != NULL) xsltEvalUserParams(ctxt, params); xsltEvalGlobalVariables(ctxt); ctxt->node = (xmlNodePtr) doc; varsPush(ctxt, NULL); xsltProcessOneNode(ctxt, ctxt->node); xsltFreeStackElemList(varsPop(ctxt)); xsltCleanupTemplates(style); /* TODO: <- style should be read only */ /* * Now cleanup our variables so stylesheet can be re-used * * TODO: this is not needed anymore global variables are copied * and not evaluated directly anymore, keep this as a check */ if (style->variables != variables) { vptr = style->variables; while (vptr->next!=variables) vptr = vptr->next; vptr->next = NULL; xsltFreeStackElemList(style->variables); style->variables = variables; } vptr = style->variables; while(vptr!=NULL) { if (vptr->computed) { if (vptr->value != NULL) { xmlXPathFreeObject(vptr->value); vptr->value = NULL; vptr->computed = 0; } } vptr = vptr->next; } /* * Do some post processing work depending on the generated output */ root = xmlDocGetRootElement(res); if (root != NULL) { /* * Apply the default selection of the method */ if ((method == NULL) && (root->ns == NULL) && (!xmlStrcasecmp(root->name, (const xmlChar *) "html"))) { xmlNodePtr tmp; tmp = res->children; while ((tmp != NULL) && (tmp != root)) { if (tmp->type == XML_ELEMENT_NODE) break; if ((tmp->type == XML_TEXT_NODE) && (!xmlIsBlankNode(tmp))) break; } if (tmp == root) { ctxt->type = XSLT_OUTPUT_HTML; res->type = XML_HTML_DOCUMENT_NODE; if (((doctypePublic != NULL) || (doctypeSystem != NULL))) res->intSubset = xmlCreateIntSubset(res, root->name, doctypePublic, doctypeSystem);#ifdef XSLT_GENERATE_HTML_DOCTYPE else { if (version == NULL) version = (const xmlChar *) "4.0"; xsltGetHTMLIDs(version, &doctypePublic, &doctypeSystem); if (((doctypePublic != NULL) || (doctypeSystem != NULL))) res->intSubset = xmlCreateIntSubset(res, root->name, doctypePublic, doctypeSystem); }#endif } } if (ctxt->type == XSLT_OUTPUT_XML) { XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic) XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem) if (((doctypePublic != NULL) || (doctypeSystem != NULL))) res->intSubset = xmlCreateIntSubset(res, root->name, doctypePublic, doctypeSystem); } } xmlXPathFreeNodeSet(ctxt->nodeList); xsltFreeTransformContext(ctxt); return(res);error: if (res != NULL) xmlFreeDoc(res); if (ctxt != NULL) xsltFreeTransformContext(ctxt); return(NULL);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/fd8a7f1b51439bbcf01b819d7cc964127181d210/transform.c/clean/kioslave/help/libxslt/transform.c
int i, second;
int i, count = 0; if (domainlist == NULL) return;
find_domain (const char *domain, ypbind_resp *result){ int i, second; pthread_rdwr_rlock_np (&domainlock); second = 0; /* Try only once to find a new server for a unbounded domain */ i = 0; while (i < max_domains) { if (strcmp (domainlist[i].domain, domain) == 0) { if (domainlist[i].active >= 0) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].server[domainlist[i].active].addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].server[domainlist[i].active].port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].server[domainlist[i].active].addr), ntohs(domainlist[i].server[domainlist[i].active].port)); break; } else if (domainlist[i].active == -2) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].ypset.addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].ypset.port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].ypset.addr), ntohs(domainlist[i].ypset.port)); break; } else { if (second) { second = 0; break; } /* Look, if we could find a new server for this domain. But only, if the other thread is not searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; /* Get the read lock again for next run. */ pthread_rdwr_rlock_np (&domainlock); continue; } else return; pthread_rdwr_rlock_np (&domainlock); } } ++i; } pthread_rdwr_runlock_np (&domainlock); return;}
5799 /local/tlutelli/issta_data/temp/c/2005_temp/2005/5799/ae2b65354c11405ebf8d8bb8f96cb40e91ad5c5b/serv_list.c/clean/src/serv_list.c
second = 0; /* Try only once to find a new server for a unbounded domain */ i = 0; while (i < max_domains)
for (i = 0; i < max_domains; ++i) if (strcmp (domainlist[i].domain, domain) == 0) break; if ( i >= max_domains)
find_domain (const char *domain, ypbind_resp *result){ int i, second; pthread_rdwr_rlock_np (&domainlock); second = 0; /* Try only once to find a new server for a unbounded domain */ i = 0; while (i < max_domains) { if (strcmp (domainlist[i].domain, domain) == 0) { if (domainlist[i].active >= 0) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].server[domainlist[i].active].addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].server[domainlist[i].active].port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].server[domainlist[i].active].addr), ntohs(domainlist[i].server[domainlist[i].active].port)); break; } else if (domainlist[i].active == -2) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].ypset.addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].ypset.port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].ypset.addr), ntohs(domainlist[i].ypset.port)); break; } else { if (second) { second = 0; break; } /* Look, if we could find a new server for this domain. But only, if the other thread is not searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; /* Get the read lock again for next run. */ pthread_rdwr_rlock_np (&domainlock); continue; } else return; pthread_rdwr_rlock_np (&domainlock); } } ++i; } pthread_rdwr_runlock_np (&domainlock); return;}
5799 /local/tlutelli/issta_data/temp/c/2005_temp/2005/5799/ae2b65354c11405ebf8d8bb8f96cb40e91ad5c5b/serv_list.c/clean/src/serv_list.c
if (strcmp (domainlist[i].domain, domain) == 0)
pthread_rdwr_runlock_np (&domainlock); return; } again: ++count; if (domainlist[i].active >= 0) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].server[domainlist[i].active].addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].server[domainlist[i].active].port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].server[domainlist[i].active].addr), ntohs(domainlist[i].server[domainlist[i].active].port)); } else if (domainlist[i].active == -2) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].ypset.addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].ypset.port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].ypset.addr), ntohs(domainlist[i].ypset.port)); } else { /* Look, if we could find a new server for this domain. But only, if the other thread is not searching already */ pthread_rdwr_runlock_np (&domainlock); if (count > 2) /* No more than 2 tries. */ return; if (pthread_mutex_trylock (&search_lock) == 0)
find_domain (const char *domain, ypbind_resp *result){ int i, second; pthread_rdwr_rlock_np (&domainlock); second = 0; /* Try only once to find a new server for a unbounded domain */ i = 0; while (i < max_domains) { if (strcmp (domainlist[i].domain, domain) == 0) { if (domainlist[i].active >= 0) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].server[domainlist[i].active].addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].server[domainlist[i].active].port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].server[domainlist[i].active].addr), ntohs(domainlist[i].server[domainlist[i].active].port)); break; } else if (domainlist[i].active == -2) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].ypset.addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].ypset.port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].ypset.addr), ntohs(domainlist[i].ypset.port)); break; } else { if (second) { second = 0; break; } /* Look, if we could find a new server for this domain. But only, if the other thread is not searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; /* Get the read lock again for next run. */ pthread_rdwr_rlock_np (&domainlock); continue; } else return; pthread_rdwr_rlock_np (&domainlock); } } ++i; } pthread_rdwr_runlock_np (&domainlock); return;}
5799 /local/tlutelli/issta_data/temp/c/2005_temp/2005/5799/ae2b65354c11405ebf8d8bb8f96cb40e91ad5c5b/serv_list.c/clean/src/serv_list.c
if (domainlist[i].active >= 0) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].server[domainlist[i].active].addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].server[domainlist[i].active].port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].server[domainlist[i].active].addr), ntohs(domainlist[i].server[domainlist[i].active].port)); break; } else if (domainlist[i].active == -2) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].ypset.addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].ypset.port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].ypset.addr), ntohs(domainlist[i].ypset.port)); break; } else { if (second) { second = 0; break; } /* Look, if we could find a new server for this domain. But only, if the other thread is not searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; /* Get the read lock again for next run. */ pthread_rdwr_rlock_np (&domainlock); continue; } else return; pthread_rdwr_rlock_np (&domainlock); }
if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]);
find_domain (const char *domain, ypbind_resp *result){ int i, second; pthread_rdwr_rlock_np (&domainlock); second = 0; /* Try only once to find a new server for a unbounded domain */ i = 0; while (i < max_domains) { if (strcmp (domainlist[i].domain, domain) == 0) { if (domainlist[i].active >= 0) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].server[domainlist[i].active].addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].server[domainlist[i].active].port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].server[domainlist[i].active].addr), ntohs(domainlist[i].server[domainlist[i].active].port)); break; } else if (domainlist[i].active == -2) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].ypset.addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].ypset.port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].ypset.addr), ntohs(domainlist[i].ypset.port)); break; } else { if (second) { second = 0; break; } /* Look, if we could find a new server for this domain. But only, if the other thread is not searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; /* Get the read lock again for next run. */ pthread_rdwr_rlock_np (&domainlock); continue; } else return; pthread_rdwr_rlock_np (&domainlock); } } ++i; } pthread_rdwr_runlock_np (&domainlock); return;}
5799 /local/tlutelli/issta_data/temp/c/2005_temp/2005/5799/ae2b65354c11405ebf8d8bb8f96cb40e91ad5c5b/serv_list.c/clean/src/serv_list.c
++i;
else { if (debug_flag) log_msg (LOG_DEBUG, "trylock = failed"); /* Another thread has the lock, ugly hack to wait until this thread is finished with search. */ pthread_mutex_lock (&search_lock); } pthread_mutex_unlock (&search_lock); /* Get the read lock again for next run. */ pthread_rdwr_rlock_np (&domainlock); goto again;
find_domain (const char *domain, ypbind_resp *result){ int i, second; pthread_rdwr_rlock_np (&domainlock); second = 0; /* Try only once to find a new server for a unbounded domain */ i = 0; while (i < max_domains) { if (strcmp (domainlist[i].domain, domain) == 0) { if (domainlist[i].active >= 0) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].server[domainlist[i].active].addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].server[domainlist[i].active].port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].server[domainlist[i].active].addr), ntohs(domainlist[i].server[domainlist[i].active].port)); break; } else if (domainlist[i].active == -2) { result->ypbind_status = YPBIND_SUCC_VAL; memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr, &domainlist[i].ypset.addr, sizeof (struct in_addr)); memcpy (&result->ypbind_resp_u.ypbind_bindinfo.ypbind_binding_port, &domainlist[i].ypset.port, sizeof (unsigned short int)); if (debug_flag) log_msg (LOG_DEBUG, "YPBINDPROC_DOMAIN: server '%s', port %d", inet_ntoa(domainlist[i].ypset.addr), ntohs(domainlist[i].ypset.port)); break; } else { if (second) { second = 0; break; } /* Look, if we could find a new server for this domain. But only, if the other thread is not searching already */ pthread_rdwr_runlock_np (&domainlock); if (pthread_mutex_trylock (&search_lock) == 0) { if (debug_flag) log_msg (LOG_DEBUG, "trylock = success"); if (!ping_all (&domainlist[i]) && domainlist[i].use_broadcast) do_broadcast (&domainlist[i]); pthread_mutex_unlock (&search_lock); ++second; /* Get the read lock again for next run. */ pthread_rdwr_rlock_np (&domainlock); continue; } else return; pthread_rdwr_rlock_np (&domainlock); } } ++i; } pthread_rdwr_runlock_np (&domainlock); return;}
5799 /local/tlutelli/issta_data/temp/c/2005_temp/2005/5799/ae2b65354c11405ebf8d8bb8f96cb40e91ad5c5b/serv_list.c/clean/src/serv_list.c
QString TOCSectionItem::url()
QString TOCChapterItem::url()
QString TOCSectionItem::url(){ if ( static_cast<TOCSectionItem *>( parent()->firstChild() ) == this ) return static_cast<TOCChapterItem *>( parent() )->url() + "#" + m_name; return "help:" + toc()->application() + "/" + m_name + ".html";}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/0caa27d8ca0ceb7745307e81df1c3c739db761ba/toc.cpp/buggy/khelpcenter/toc.cpp
if ( static_cast<TOCSectionItem *>( parent()->firstChild() ) == this ) return static_cast<TOCChapterItem *>( parent() )->url() + "#" + m_name;
QString TOCSectionItem::url(){ if ( static_cast<TOCSectionItem *>( parent()->firstChild() ) == this ) return static_cast<TOCChapterItem *>( parent() )->url() + "#" + m_name; return "help:" + toc()->application() + "/" + m_name + ".html";}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/0caa27d8ca0ceb7745307e81df1c3c739db761ba/toc.cpp/buggy/khelpcenter/toc.cpp
transformation_hint);
labels_transformation);
finish_constraint_and_action(void){ unsigned int i; float cost; int have_constraint = (pattern[patno].autohelper_flag & HAVE_CONSTRAINT); int have_action = (pattern[patno].autohelper_flag & HAVE_ACTION); int no_labels = 1; /* Mark that this pattern has an autohelper. */ pattern[patno].autohelper = dummyhelper; /* Generate autohelper function declaration. */ code_pos += sprintf(code_pos, "static int\nautohelper%s%d(int trans, int move, int color, int action)\n{\n int", prefix, patno); /* Generate variable declarations. */ for (i = 0; i < sizeof(VALID_CONSTRAINT_LABELS); i++) { int c = (int) VALID_CONSTRAINT_LABELS[i]; if (label_coords[c][0] != -1) code_pos += sprintf(code_pos, " %c,", c); } /* Replace the last ',' with ';' */ if (*(code_pos-1) == ',') *(code_pos-1) = ';'; else { code_pos -= 3; /* no variable, erase "int" */ code_pos += sprintf(code_pos, "UNUSED(trans);"); } /* Include UNUSED statements for two parameters */ code_pos += sprintf(code_pos, "\n UNUSED(color);\n"); if (!have_constraint || !have_action) code_pos += sprintf(code_pos, " UNUSED(action);\n"); /* Generate coordinate transformations. */ for (i = 0; i < sizeof(VALID_CONSTRAINT_LABELS); i++) { int c = (int) VALID_CONSTRAINT_LABELS[i]; if (label_coords[c][0] != -1) { int x; int y; TRANSFORM2(label_coords[c][0] - ci - movei, label_coords[c][1] - cj - movej, &x, &y, transformation_hint); code_pos += sprintf(code_pos, "\n %c = AFFINE_TRANSFORM(%d, trans, move);", c, OFFSET(x, y)); no_labels = 0; } } /* move might be unused. Add an UNUSED statement to avoid warnings. */ if (no_labels) code_pos += sprintf(code_pos, "\n UNUSED(move);"); code_pos += sprintf(code_pos, "\n\n"); if (have_constraint && have_action) code_pos += sprintf(code_pos, " if (!action)\n "); if (have_constraint) { code_pos += sprintf(code_pos, " return "); parse_constraint_or_action(constraint, &cost); pattern[patno].constraint_cost = cost; code_pos += sprintf(code_pos, ";\n"); } if (have_action) { code_pos += sprintf(code_pos, " "); parse_constraint_or_action(action, &cost); code_pos += sprintf(code_pos, ";\n"); code_pos += sprintf(code_pos, "\n return 0;\n"); } code_pos += sprintf(code_pos, "}\n\n"); /* Check that we have not overrun our buffer. That would be really bad. */ assert(code_pos <= autohelper_code + sizeof(autohelper_code));}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/850975f42c223308c9f6bfd669945ab33a010243/mkpat.c/buggy/patterns/mkpat.c
QString TOCChapterItem::url()
QString TOCSectionItem::url()
QString TOCChapterItem::url(){ return "help:" + toc()->application() + "/" + m_name + ".html";}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/be62308ae1b9cba7c1daee3a9d133feb513997d0/toc.cpp/clean/khelpcenter/toc.cpp
if ( static_cast<TOCSectionItem *>( parent()->firstChild() ) == this ) return static_cast<TOCChapterItem *>( parent() )->url() + "#" + m_name;
QString TOCChapterItem::url(){ return "help:" + toc()->application() + "/" + m_name + ".html";}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/be62308ae1b9cba7c1daee3a9d133feb513997d0/toc.cpp/clean/khelpcenter/toc.cpp
(*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrTextBk, (jint)lpStruct->clrTextBk); (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrText, (jint)lpStruct->clrText);
void setNMTVCUSTOMDRAWFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpStruct){ if (!NMTVCUSTOMDRAWFc.cached) cacheNMTVCUSTOMDRAWFields(env, lpObject); setNMCUSTOMDRAWFields(env, lpObject, (NMCUSTOMDRAW *)lpStruct);#ifndef _WIN32_WCE (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.iLevel, (jint)lpStruct->iLevel);#endif (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrTextBk, (jint)lpStruct->clrTextBk); (*env)->SetIntField(env, lpObject, NMTVCUSTOMDRAWFc.clrText, (jint)lpStruct->clrText);}
11867 /local/tlutelli/issta_data/temp/c/2005_temp/2005/11867/87f953c8eda7bc7ceddf6227acc0065974196814/structs.c/buggy/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
str.sprintf("<A HREF=\"man:/%s(%c,%c)\">%s</A>", h, sec, tolower(subsec), h);
str.sprintf("<A HREF=\"man:/%s(%c%c)\">%s</A>", h, sec, tolower(subsec), h);
static void add_links(char *c){ /* ** Add the links to the output. ** At the moment the following are recognized: ** ** name(*) -> ../man?/name.* ** method://string -> method://string ** www.host.name -> http://www.host.name ** ftp.host.name -> ftp://ftp.host.name ** name@host -> mailto:name@host ** <name.h> -> file:/usr/include/name.h (guess) ** ** Other possible links to add in the future: ** ** /dir/dir/file -> file:/dir/dir/file */ int i,j,nr; char *f, *g,*h; char *idtest[6]; /* url, mailto, www, ftp, manpage */ out_length+=strlen(c); /* search for (section) */ nr=0; idtest[0]=strstr(c+1,"://"); idtest[1]=strchr(c+1,'@'); idtest[2]=strstr(c,"www."); idtest[3]=strstr(c,"ftp."); idtest[4]=strchr(c+1,'('); idtest[5]=strstr(c+1,".h&gt;"); for (i=0; i<6; i++) nr += (idtest[i]!=NULL); while (nr) { j=-1; for (i=0; i<6; i++) if (idtest[i] && (j<0 || idtest[i]<idtest[j])) j=i; switch (j) { case 5: { /* <name.h> */ f=idtest[5]; h=f+2; g=f; while (g>c && g[-1]!=';') g--; bool wrote_include = false; if (g!=c) { QCString dir; QCString file(g, h - g + 1); file = file.stripWhiteSpace(); for (int index = 0; includedirs[index]; index++) { QCString str = QCString(includedirs[index]) + "/" + file; if (!access(str, R_OK)) { dir = includedirs[index]; break; } } if (!dir.isEmpty()) { char t; t=*g; *g=0; output_real(c); *g=t;*h=0; QCString str; str.sprintf("<A HREF=\"file:%s/%s\">%s</A>&gt;", dir.data(), file.data(), file.data()); output_real(str.data()); c=f+6; wrote_include = true; } } if (!wrote_include) { f[5]=0; output_real(c); f[5]=';'; c=f+5; } } break; case 4: /* manpage */ f=idtest[j]; /* check section */ g=strchr(f,')'); if (g && f-g<6 && (isalnum(f[-1]) || f[-1]=='>') && ((isdigit(f[1]) && f[1]!='0' && (f[2]==')' || (isalpha(f[2]) && f[3]==')') || f[2]=='X')) || (f[2]==')' && (f[1]=='n' || f[1]=='l')))) { /* this might be a link */ h=f-1; /* skip html makeup */ while (h>c && *h=='>') { while (h!=c && *h!='<') h--; if (h!=c) h--; } if (isalnum(*h)) { char t,sec,subsec, *e; e=h+1; sec=f[1]; subsec=f[2]; if ((subsec=='X' && f[3]!=')')|| subsec==')') subsec='\0'; while (h>c && (isalnum(h[-1]) || h[-1]=='_' || h[-1]==':' || h[-1]=='-' || h[-1]=='.')) h--; t=*h; *h='\0'; output_real(c); *h=t; t=*e; *e='\0'; QCString str; if (subsec) str.sprintf("<A HREF=\"man:/%s(%c,%c)\">%s</A>", h, sec, tolower(subsec), h); else str.sprintf("<A HREF=\"man:/%s(%c)\">%s</A>", h, sec, h); output_real(str.data()); *e=t; c=e; } } *f='\0'; output_real(c); *f='('; idtest[4]=f-1; c=f; break; /* manpage */ case 3: /* ftp */ case 2: /* www */ g=f=idtest[j]; while (*g && (isalnum(*g) || *g=='_' || *g=='-' || *g=='+' || *g=='.')) g++; if (g[-1]=='.') g--; if (g-f>4) { char t; t=*f; *f='\0'; output_real(c); *f=t; t=*g;*g='\0'; QCString str; str.sprintf("<A HREF=\"%s://%s\">%s</A>", ((j==3)?"ftp":"http"), f, f); output_real(str.data()); *g=t; c=g; } else { f[3]='\0'; output_real(c); c=f+3; f[3]='.'; } break; case 1: /* mailto */ g=f=idtest[1]; while (g>c && (isalnum(g[-1]) || g[-1]=='_' || g[-1]=='-' || g[-1]=='+' || g[-1]=='.' || g[-1]=='%')) g--; h=f+1; while (*h && (isalnum(*h) || *h=='_' || *h=='-' || *h=='+' || *h=='.')) h++; if (*h=='.') h--; if (h-f>4 && f-g>1) { char t; t=*g; *g='\0'; output_real(c); *g=t;t=*h;*h='\0'; QCString str; str.sprintf("<A HREF=\"mailto:%s\">%s</A>", g, g); output_real(str.data()); *h=t; c=h; } else { *f='\0'; output_real(c); *f='@'; idtest[1]=c; c=f; } break; case 0: /* url */ g=f=idtest[0]; while (g>c && isalpha(g[-1]) && islower(g[-1])) g--; h=f+3; while (*h && !isspace(*h) && *h!='<' && *h!='>' && *h!='"' && *h!='&') h++; if (f-g>2 && f-g<7 && h-f>3) { char t; t=*g; *g='\0'; output_real(c); *g=t; t=*h; *h='\0'; QCString str; str.sprintf("<A HREF=\"%s\">%s</A>", g, g); output_real(str.data()); *h=t; c=h; } else { f[1]='\0'; output_real(c); f[1]='/'; c=f+1; } break; default: break; } nr=0; if (idtest[0] && idtest[0]<c) idtest[0]=strstr(c+1,"://"); if (idtest[1] && idtest[1]<c) idtest[1]=strchr(c+1,'@'); if (idtest[2] && idtest[2]<c) idtest[2]=strstr(c,"www."); if (idtest[3] && idtest[3]<c) idtest[3]=strstr(c,"ftp."); if (idtest[4] && idtest[4]<c) idtest[4]=strchr(c+1,'('); if (idtest[5] && idtest[5]<c) idtest[5]=strstr(c+1,".h&gt;"); for (i=0; i<6; i++) nr += (idtest[i]!=NULL); } output_real(c);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/c03d7de0f8eb0b2b296c6ccb46aabc16d761d943/man2html.cpp/buggy/kioslave/man/man2html.cpp
kdDebug() << "Full path given to kcmshell - not supported yet" << endl;
kdDebug(1208) << "Full path given to kcmshell - not supported yet" << endl;
static QString locateModule(const QCString module){ // locate the desktop file //QStringList files; if (module[0] == '/') { kdDebug() << "Full path given to kcmshell - not supported yet" << endl; // (because of KService::findServiceByDesktopPath) //files.append(args->arg(0)); } QString path = KCGlobal::baseGroup(); path += module; path += ".desktop"; if (!KService::serviceByDesktopPath( path )) { // Path didn't work. Trying as a name KService::Ptr serv = KService::serviceByDesktopName( module ); if ( serv ) path = serv->entryPath(); else { kdError(1208) << i18n("Module %1 not found!").arg(module) << endl; return QString::null; } } return path;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/1358c70a9564cd327c27ff2fe7ae98d914f2e449/kcmshell.cpp/buggy/kcontrol/kcontrol/kcmshell.cpp
( void )KGlobal::locale()->charset();
int kdemain( int argc, char **argv ) { KInstance instance( "kio_help" ); ( void )KGlobal::locale()->charset(); fillInstance(instance); (void)instance.config(); // we need this one to make sure system globals are read kdDebug(7101) << "Starting " << getpid() << endl; if (argc != 4) { fprintf(stderr, "Usage: kio_help protocol domain-socket1 domain-socket2\n"); exit(-1); } LIBXML_TEST_VERSION xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; xmlSetExternalEntityLoader(meinExternalEntityLoader); HelpProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); kdDebug(7101) << "Done" << endl; return 0; }
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/4440216bb629b9983eabbb9588661d19a7355ad1/main.cpp/clean/kioslave/help/main.cpp
signal(SIGINT,&destruct); signal(SIGQUIT,&destruct); signal(SIGILL,&destruct); signal(SIGTRAP,&destruct); signal(SIGABRT,&destruct); signal(SIGBUS,&destruct); signal(SIGSEGV,&destruct); signal(SIGUSR2,&destruct); signal(SIGPIPE,&destruct); signal(SIGALRM,&destruct); signal(SIGTERM,&destruct); signal(SIGFPE,&destruct); #ifdef SIGPOLL signal(SIGPOLL, &destruct); #endif #ifdef SIGSYS signal(SIGSYS, &destruct); #endif #ifdef SIGVTALRM signal(SIGVTALRM, &destruct); #endif #ifdef SIGXCPU signal(SIGXCPU, &destruct); #endif #ifdef SIGXFSZ signal(SIGXFSZ, &destruct); #endif SmbProtocol *slave=new SmbProtocol(argv[2], argv[3]); globalSlave=slave; slave->dispatchLoop();
SmbProtocol slave(argv[2], argv[3]); slave.dispatchLoop();
int kdemain( int argc, char **argv ){ KLocale::setMainCatalogue("kio_smbro"); KInstance instance( "kio_smb" ); if (argc != 4) { fprintf(stderr, "Usage: kio_smb protocol domain-socket1 domain-socket2\n"); exit(-1); } //kdDebug(7101) << "Smb: kdemain: starting" << endl; signal(SIGINT,&destruct); signal(SIGQUIT,&destruct); signal(SIGILL,&destruct); signal(SIGTRAP,&destruct); signal(SIGABRT,&destruct); signal(SIGBUS,&destruct); signal(SIGSEGV,&destruct); signal(SIGUSR2,&destruct); signal(SIGPIPE,&destruct); signal(SIGALRM,&destruct); signal(SIGTERM,&destruct); signal(SIGFPE,&destruct);#ifdef SIGPOLL signal(SIGPOLL, &destruct);#endif#ifdef SIGSYS signal(SIGSYS, &destruct);#endif#ifdef SIGVTALRM signal(SIGVTALRM, &destruct);#endif#ifdef SIGXCPU signal(SIGXCPU, &destruct);#endif#ifdef SIGXFSZ signal(SIGXFSZ, &destruct);#endif SmbProtocol *slave=new SmbProtocol(argv[2], argv[3]); globalSlave=slave; slave->dispatchLoop(); return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/6a33dd738f9e92b8892b02c148ab883ad0d89867/kio_smb.cpp/buggy/kioslave/smbro/kio_smb.cpp
if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0); if (arg11) setCREATESTRUCTFields(env, arg11, lparg11);
JNIEXPORT jint JNICALL OS_NATIVE(CreateWindowExW) (JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jcharArray arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jobject arg11){ jchar *lparg1=NULL; jchar *lparg2=NULL; CREATESTRUCT _arg11, *lparg11=NULL; jint rc; NATIVE_ENTER(env, that, "CreateWindowExW\n") if (arg1) lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL); if (arg2) lparg2 = (*env)->GetCharArrayElements(env, arg2, NULL); if (arg11) lparg11 = getCREATESTRUCTFields(env, arg11, &_arg11); rc = (jint)CreateWindowExW(arg0, (LPWSTR)lparg1, (LPWSTR)lparg2, arg3, arg4, arg5, arg6, arg7, (HWND)arg8, (HMENU)arg9, (HINSTANCE)arg10, lparg11); if (arg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, 0); if (arg2) (*env)->ReleaseCharArrayElements(env, arg2, lparg2, 0); if (arg11) setCREATESTRUCTFields(env, arg11, lparg11); NATIVE_EXIT(env, that, "CreateWindowExW\n") return rc;}
11867 /local/tlutelli/issta_data/temp/c/2005_temp/2005/11867/53f673e459d608e26914cfa9d40023f64288ef94/os.c/buggy/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
DEBUG_CHECK_NULL(env, arg0)
JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__I_3SI (JNIEnv *env, jclass that, jint arg0, jshortArray arg1, jint arg2){ jshort *lparg1=NULL; DEBUG_CALL("MoveMemory\n") if (arg1) lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL); MoveMemory((PVOID)arg0, (CONST VOID *)lparg1, arg2); if (arg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, 0);}
11867 /local/tlutelli/issta_data/temp/c/2005_temp/2005/11867/ea8b10752d0a908b46d628e28b8b2033139f866e/swt.c/buggy/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/swt.c
if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL);
if (arg3) lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL);
JNIEXPORT jint JNICALL OS_NATIVE(SetDIBColorTable) (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3){ jbyte *lparg3=NULL; jint rc; NATIVE_ENTER(env, that, "SetDIBColorTable\n") if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL); rc = (jint)SetDIBColorTable((HDC)arg0, arg1, arg2, (RGBQUAD *)lparg3); if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, JNI_ABORT); NATIVE_EXIT(env, that, "SetDIBColorTable\n") return rc;}
11867 /local/tlutelli/issta_data/temp/c/2005_temp/2005/11867/53f673e459d608e26914cfa9d40023f64288ef94/os.c/buggy/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, JNI_ABORT);
if (arg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, JNI_ABORT);
JNIEXPORT jint JNICALL OS_NATIVE(SetDIBColorTable) (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3){ jbyte *lparg3=NULL; jint rc; NATIVE_ENTER(env, that, "SetDIBColorTable\n") if (arg3) lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL); rc = (jint)SetDIBColorTable((HDC)arg0, arg1, arg2, (RGBQUAD *)lparg3); if (arg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, JNI_ABORT); NATIVE_EXIT(env, that, "SetDIBColorTable\n") return rc;}
11867 /local/tlutelli/issta_data/temp/c/2005_temp/2005/11867/53f673e459d608e26914cfa9d40023f64288ef94/os.c/buggy/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
kdDebug(1205) << "PID " << (int) pid << "exited\n";
kdDebug(1205) << "PID " << (int) pid << " exited\n";
void sigchld_handler(int){ int status; pid_t pid; while (1) { pid = waitpid((pid_t) -1, &status, WNOHANG); if (pid <= 0) break; kdDebug(1205) << "PID " << (int) pid << "exited\n"; }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/bc57e4f531c373b7d10b518df368d51750e67136/kdesud.cpp/clean/kdesu/kdesud/kdesud.cpp
kdError() << "Usage: kio_thumbnail protocol domain-socket1 domain-socket2" << endl;
kdError(7115) << "Usage: kio_thumbnail protocol domain-socket1 domain-socket2" << endl;
int kdemain(int argc, char **argv){ nice( 5 ); // creating KApplication in a slave in not a very good idea, // as dispatchLoop() doesn't allow it to process its messages, // so it for example wouldn't reply to ksmserver - on the other // hand, this slave uses QPixmaps for some reason, and they // need QApplication // and HTML previews need even KApplication :( putenv(strdup("SESSION_MANAGER=")); KApplication::disableAutoDcopRegistration(); KApplication app(argc, argv, "kio_thumbnail", false, true); if (argc != 4) { kdError() << "Usage: kio_thumbnail protocol domain-socket1 domain-socket2" << endl; exit(-1); } ThumbnailProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/36fe223ef8128c8c443250c3d3eba7c0daa4e0fd/thumbnail.cpp/clean/kioslave/thumbnail/thumbnail.cpp
prop = xmlGetNsProp(inst, (const xmlChar *)"terminate", XSLT_NAMESPACE);
prop = xsltGetNsProp(inst, (const xmlChar *)"terminate", XSLT_NAMESPACE);
xsltMessage(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst) { xmlChar *prop, *message; int terminate = 0; if ((ctxt == NULL) || (inst == NULL)) return; prop = xmlGetNsProp(inst, (const xmlChar *)"terminate", XSLT_NAMESPACE); if (prop != NULL) { if (xmlStrEqual(prop, (const xmlChar *)"yes")) { terminate = 1; } else if (xmlStrEqual(prop, (const xmlChar *)"yes")) { terminate = 0; } else { xsltGenericError(xsltGenericErrorContext, "xsl:message : terminate expecting 'yes' or 'no'\n"); } xmlFree(prop); } message = xsltEvalTemplateString(ctxt, node, inst); if (message != NULL) { int len = xmlStrlen(message); xsltGenericError(xsltGenericErrorContext, (const char *)message); if ((len > 0) && (message[len - 1] != '\n')) xsltGenericError(xsltGenericErrorContext, "\n"); xmlFree(message); } if (terminate) ctxt->state = XSLT_STATE_STOPPED;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/fd8a7f1b51439bbcf01b819d7cc964127181d210/xsltutils.c/clean/kioslave/help/libxslt/xsltutils.c
xsltGetKey(xsltTransformContextPtr ctxt, const xmlChar *name, const xmlChar *nameURI, const xmlChar *value) { xmlNodeSetPtr ret; xsltKeyTablePtr table; if ((ctxt == NULL) || (name == NULL) || (value == NULL)) return(NULL);#ifdef WITH_XSLT_DEBUG_KEYS xsltGenericDebug(xsltGenericDebugContext, "Get key %s, value %s\n", name, value);#endif table = (xsltKeyTablePtr) ctxt->document->keys; while (table != NULL) { if (xmlStrEqual(table->name, name) && (((nameURI == NULL) && (table->nameURI == NULL)) || ((nameURI != NULL) && (table->nameURI != NULL) && (xmlStrEqual(table->nameURI, nameURI))))) { ret = (xmlNodeSetPtr)xmlHashLookup(table->keys, value); return(ret); } table = table->next; } return(NULL);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/fd8a7f1b51439bbcf01b819d7cc964127181d210/keys.c/clean/kioslave/help/libxslt/keys.c
&& dragon[pos].owl_defense_point != NO_MOVE)
&& dragon[pos].owl_defense_point != NO_MOVE) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/2657b9ef2bf196b0f6aae0f01dfe0ceae0f44437/owl.c/clean/engine/owl.c
&& is_legal(dragon[pos].owl_second_defense_point, color))
&& is_legal(dragon[pos].owl_second_defense_point, color)) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/2657b9ef2bf196b0f6aae0f01dfe0ceae0f44437/owl.c/clean/engine/owl.c
&& dragon[pos].owl_attack_point != NO_MOVE)
&& dragon[pos].owl_attack_point != NO_MOVE) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/2657b9ef2bf196b0f6aae0f01dfe0ceae0f44437/owl.c/clean/engine/owl.c
if (dragon[pos].owl_attack_point != NO_MOVE)
if (dragon[pos].owl_attack_point != NO_MOVE) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/2657b9ef2bf196b0f6aae0f01dfe0ceae0f44437/owl.c/clean/engine/owl.c
&& is_legal(dragon[pos].owl_second_attack_point, color))
&& is_legal(dragon[pos].owl_second_attack_point, color)) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/2657b9ef2bf196b0f6aae0f01dfe0ceae0f44437/owl.c/clean/engine/owl.c
&& ON_BOARD(dragon[pos].owl_defense_point))
&& ON_BOARD(dragon[pos].owl_defense_point)) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/2657b9ef2bf196b0f6aae0f01dfe0ceae0f44437/owl.c/clean/engine/owl.c
&& ON_BOARD(dragon[pos].owl_attack_point))
&& ON_BOARD(dragon[pos].owl_attack_point)) {
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/2657b9ef2bf196b0f6aae0f01dfe0ceae0f44437/owl.c/clean/engine/owl.c
DEBUG(DEBUG_OWL, "owl: %1m might defend the uncertain dragon at %1m at move %d\n", dragon[pos].owl_attack_point, pos, movenum+1); }
owl_reasons(int color){ int pos; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (dragon[pos].origin == pos && dragon[pos].matcher_status == CRITICAL && dragon[pos].owl_attack_point != NO_MOVE) { if (board[pos] == color) { if (dragon[pos].owl_defense_point != NO_MOVE) { add_owl_defense_move(dragon[pos].owl_defense_point, pos, dragon[pos].owl_defense_code); DEBUG(DEBUG_OWL, "owl: %1m defends %1m at move %d\n", dragon[pos].owl_defense_point, pos, movenum+1); } } else { /* opponent's dragon */ /* We don't want to add this move reason if the attacker * dies because the victim only formed a nakade shape. * * FIXME: This code overlaps heavily with some code in * examine_move_safety() in move_reasons.c. The caching * scheme should minimize the performance hit, but of course * it's unfortunate to have the code duplication. */ int move = dragon[pos].owl_attack_point; /* No worries if we catch something big. */ if (dragon[pos].effective_size < 8) { /* Look through the neighbors of the victim for dragons of * our color. If we find at least one being thought alive * everything is ok. Otherwise we keep track of the * largest one for further examination. */ int largest = 0; int k; int bpos = NO_MOVE; int safe = 0; for (k = 0; k < DRAGON2(pos).neighbors; k++) { int d = DRAGON2(pos).adjacent[k]; if (DRAGON(d).color == color) { if (DRAGON(d).matcher_status == ALIVE) { safe = 1; break; } if (DRAGON(d).size > largest) { bpos = dragon2[d].origin; largest = DRAGON(d).size; } } } /* It may occasionally happen that no neighbor of our * color was found. Assume safe in that case. */ if (bpos == NO_MOVE) safe = 1; /* If not yet thought safe, ask the owl code whether the * owl attack defends the (largest) attacker. */ if (!safe && owl_does_defend(move, bpos) != WIN) { DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d, but the attacker dies.\n", move, pos, movenum+1); DRAGON2(pos).safety = INESSENTIAL; continue; } } /* If we've reached this far, the attack is okay. */ add_owl_attack_move(move, pos, dragon[pos].owl_attack_code); DEBUG(DEBUG_OWL, "owl: %1m attacks %1m at move %d\n", move, pos, movenum+1); } } else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE) { if (board[pos] == color && dragon[pos].owl_defense_point != NO_MOVE) add_owl_defense_threat_move(dragon[pos].owl_defense_point, pos, WIN); if (board[pos] == color && dragon[pos].owl_second_defense_point != NO_MOVE && is_legal(dragon[pos].owl_second_defense_point, color)) add_owl_defense_threat_move(dragon[pos].owl_second_defense_point, pos, WIN); /* If the opponent can threaten to live, an attacking * move gets a small value to make sure it's really dead. */ if (board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_DEFENSE && dragon[pos].owl_attack_point != NO_MOVE) add_owl_prevent_threat_move(dragon[pos].owl_attack_point, pos); } else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == OTHER_COLOR(color) && dragon[pos].owl_threat_status == CAN_THREATEN_ATTACK) { if (dragon[pos].owl_attack_point != NO_MOVE) add_owl_attack_threat_move(dragon[pos].owl_attack_point, pos, WIN); if (dragon[pos].owl_second_attack_point != NO_MOVE && is_legal(dragon[pos].owl_second_attack_point, color)) add_owl_attack_threat_move(dragon[pos].owl_second_attack_point, pos, WIN); } /* The owl code found the friendly dragon alive, but was uncertain, * and an extra point of defense was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == ALIVE && board[pos] == color && !dragon[pos].owl_attack_certain && dragon[pos].owl_defense_certain && ON_BOARD(dragon[pos].owl_defense_point)) add_owl_uncertain_defense_move(dragon[pos].owl_defense_point, pos); /* The owl code found the dragon dead, but was uncertain, * and an extra point of attack was found, so this might * be a good place to play. */ else if (dragon[pos].origin == pos && dragon[pos].owl_status == DEAD && board[pos] == OTHER_COLOR(color) && !dragon[pos].owl_attack_certain && ON_BOARD(dragon[pos].owl_attack_point)) add_owl_uncertain_defense_move(dragon[pos].owl_attack_point, pos); }}
6496 /local/tlutelli/issta_data/temp/c/2005_temp/2005/6496/2657b9ef2bf196b0f6aae0f01dfe0ceae0f44437/owl.c/clean/engine/owl.c
lpStruct->dwSize = (*env)->GetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwSize);
INITCOMMONCONTROLSEX *getINITCOMMONCONTROLSEXFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpStruct){ if (!INITCOMMONCONTROLSEXFc.cached) cacheINITCOMMONCONTROLSEXFields(env, lpObject); lpStruct->dwICC = (*env)->GetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwICC); lpStruct->dwSize = (*env)->GetIntField(env, lpObject, INITCOMMONCONTROLSEXFc.dwSize); return lpStruct;}
11867 /local/tlutelli/issta_data/temp/c/2005_temp/2005/11867/87f953c8eda7bc7ceddf6227acc0065974196814/structs.c/buggy/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/structs.c
QDataStream& operator>> (QDataStream& s, sftpFileAttr& fa) { // XXX set all member variable to defaults // XXX Add some error checking in here in case // we get a bad sftp packet. fa.clear(); if( fa.mDirAttrs ) { QByteArray fn; s >> fn; KRemoteEncoding encoder ( fa.mEncoding.data() ); fa.mFilename = encoder.decode( QCString(fn.data(), fn.size()+1) ); s >> fa.mLongname; fa.mLongname.truncate( fa.mLongname.size() ); //kdDebug() << ">>: ftpfileattr long filename (" << fa.mLongname.size() << ")= " << fa.mLongname << endl; } s >> fa.mFlags; // get flags if( fa.mFlags & SSH2_FILEXFER_ATTR_SIZE ) { Q_ULLONG fileSize; s >> fileSize; fa.setFileSize(fileSize); } Q_UINT32 x; if( fa.mFlags & SSH2_FILEXFER_ATTR_UIDGID ) { s >> x; fa.setUid(x); s >> x; fa.setGid(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_PERMISSIONS ) { s >> x; fa.setPermissions(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_ACMODTIME ) { s >> x; fa.setAtime(x); s >> x; fa.setMtime(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_EXTENDED ) { s >> x; fa.setExtendedCount(x); // XXX: Read in extensions from data stream here // s.readBytes(extendedtype).readBytes(extendeddata); } fa.getUserGroupNames(); return s;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/e565253604f9d1266484ff88d46c2957283f736a/sftpfileattr.cpp/clean/kioslave/sftp/sftpfileattr.cpp
QByteArray fn;
QCString fn;
QDataStream& operator>> (QDataStream& s, sftpFileAttr& fa) { // XXX set all member variable to defaults // XXX Add some error checking in here in case // we get a bad sftp packet. fa.clear(); if( fa.mDirAttrs ) { QByteArray fn; s >> fn; KRemoteEncoding encoder ( fa.mEncoding.data() ); fa.mFilename = encoder.decode( QCString(fn.data(), fn.size()+1) ); s >> fa.mLongname; fa.mLongname.truncate( fa.mLongname.size() ); //kdDebug() << ">>: ftpfileattr long filename (" << fa.mLongname.size() << ")= " << fa.mLongname << endl; } s >> fa.mFlags; // get flags if( fa.mFlags & SSH2_FILEXFER_ATTR_SIZE ) { Q_ULLONG fileSize; s >> fileSize; fa.setFileSize(fileSize); } Q_UINT32 x; if( fa.mFlags & SSH2_FILEXFER_ATTR_UIDGID ) { s >> x; fa.setUid(x); s >> x; fa.setGid(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_PERMISSIONS ) { s >> x; fa.setPermissions(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_ACMODTIME ) { s >> x; fa.setAtime(x); s >> x; fa.setMtime(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_EXTENDED ) { s >> x; fa.setExtendedCount(x); // XXX: Read in extensions from data stream here // s.readBytes(extendedtype).readBytes(extendeddata); } fa.getUserGroupNames(); return s;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/e565253604f9d1266484ff88d46c2957283f736a/sftpfileattr.cpp/clean/kioslave/sftp/sftpfileattr.cpp
KRemoteEncoding encoder ( fa.mEncoding.data() ); fa.mFilename = encoder.decode( QCString(fn.data(), fn.size()+1) );
KRemoteEncoding encoder ( encoding.data() ); fa.mFilename = encoder.decode( fn );
QDataStream& operator>> (QDataStream& s, sftpFileAttr& fa) { // XXX set all member variable to defaults // XXX Add some error checking in here in case // we get a bad sftp packet. fa.clear(); if( fa.mDirAttrs ) { QByteArray fn; s >> fn; KRemoteEncoding encoder ( fa.mEncoding.data() ); fa.mFilename = encoder.decode( QCString(fn.data(), fn.size()+1) ); s >> fa.mLongname; fa.mLongname.truncate( fa.mLongname.size() ); //kdDebug() << ">>: ftpfileattr long filename (" << fa.mLongname.size() << ")= " << fa.mLongname << endl; } s >> fa.mFlags; // get flags if( fa.mFlags & SSH2_FILEXFER_ATTR_SIZE ) { Q_ULLONG fileSize; s >> fileSize; fa.setFileSize(fileSize); } Q_UINT32 x; if( fa.mFlags & SSH2_FILEXFER_ATTR_UIDGID ) { s >> x; fa.setUid(x); s >> x; fa.setGid(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_PERMISSIONS ) { s >> x; fa.setPermissions(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_ACMODTIME ) { s >> x; fa.setAtime(x); s >> x; fa.setMtime(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_EXTENDED ) { s >> x; fa.setExtendedCount(x); // XXX: Read in extensions from data stream here // s.readBytes(extendedtype).readBytes(extendeddata); } fa.getUserGroupNames(); return s;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/e565253604f9d1266484ff88d46c2957283f736a/sftpfileattr.cpp/clean/kioslave/sftp/sftpfileattr.cpp
expr = xmlGetNsProp(node, name, ns);
expr = xsltGetNsProp(node, name, ns);
xsltEvalStaticAttrValueTemplate(xsltStylesheetPtr style, xmlNodePtr node, const xmlChar *name, const xmlChar *ns, int *found) { const xmlChar *ret; xmlChar *expr; if ((style == NULL) || (node == NULL) || (name == NULL)) return(NULL); expr = xmlGetNsProp(node, name, ns); if (expr == NULL) { *found = 0; return(NULL); } *found = 1; ret = xmlStrchr(expr, '{'); if (ret != NULL) { xmlFree(expr); return(NULL); } return(expr);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/fd8a7f1b51439bbcf01b819d7cc964127181d210/templates.c/buggy/kioslave/help/libxslt/templates.c
const QString & getContinuation ()
const QByteArray & getContinuation ()
const QString & getContinuation () { return continuation; };
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/dc7a5382448d268f8f67906021462f026ab61846/imapparser.h/clean/kioslave/imap4/imapparser.h
qInstallMsgHandler(msgHandler);
KAboutData aboutData("kdesu", I18N_NOOP("KDE su"), Version, I18N_NOOP("Runs a program under a different uid."), KAboutData::Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Maintainer"), "[email protected]", "http: aboutData.addAuthor("Pietro Iglio", I18N_NOOP("Original author"), "[email protected]");
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
QString command, file; bool keep = true; bool terminal = false;
KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
KStartParams parm(argc, argv); QString s; uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp);
if (args->isSet("s")) { KDEsuClient client; if (client.ping() == -1) kDebugFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); exit(0); } kDebugFatal("Could not stop daemon");
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0;
QCString user = args->getOption("u"); struct passwd *pw = getpwnam(user); if (pw == 0L) { kDebugFatal("User %s does not exist", (const char *) user); exit(1); } uid_t uid = pw->pw_uid; bool change_uid = (getuid() != uid); if (args->count() == 0) KCmdLineArgs::usage(i18n("No command specified!")); QCString command = args->arg(0); for (int i=1; i<args->count(); i++) { command += " "; command += args->arg(i);
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } bool change_uid = (getuid() != uid);
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
if (change_uid && !file.isEmpty()) {
QString file = QFile::decodeName(args->getOption("f")); if (!file.isEmpty()) {
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
if (!fi.exists()) qFatal("File does not exist: %s", file.latin1());
if (!fi.exists()) { kDebugFatal("File does not exist: %s", file.latin1()); exit(1); }
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno));
if (setrlimit(RLIMIT_CORE, &rlim)) { kDebugFatal("rlimit(): %s", strerror(errno)); exit(1); }
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
KApplication *app = new KApplication(argc, argv, "kdesu");
KApplication *app = new KApplication;
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user,
KDEsuDialog *dlg = new KDEsuDialog(command, user,
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
pwDlg->setEchoMode(echo_mode); pwDlg->exec();
dlg->setEchoMode(echo_mode); dlg->exec();
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass());
switch (dlg->result()) { case KDEsuDialog::Accepted: strcpy(pass, dlg->getPass());
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
case KPasswordDlg::Rejected:
case KDEsuDialog::Rejected:
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
case KPasswordDlg::AsUser:
case KDEsuDialog::AsUser:
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
keep = pwDlg->keepPass(); delete pwDlg;
keep = dlg->keepPass(); delete dlg;
int main(int argc, char *argv[]){ qInstallMsgHandler(msgHandler); QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) qFatal("User %s does not exist", s.latin1()); user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { printf(Usage); printf(TryHelp); exit(1); } bool next = false; for (unsigned int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); exit(0); case 'h': printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); if (client.stopServer() != -1) { printf("Daemon stopped\n"); return 0; } qFatal("Could not stop daemon"); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { printf(Usage); printf(TryHelp); exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else qWarning("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/07cd7a58da6d34c36c18d3daa523366915677e4a/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
kdDebug(7101)<<"exiting normally"<<endl;
int kdemain( int argc, char **argv ){ KLocale::setMainCatalogue("kio_smbro"); KInstance instance( "kio_smb" ); if (argc != 4) { fprintf(stderr, "Usage: kio_smb protocol domain-socket1 domain-socket2\n"); exit(-1); } //kdDebug(7101) << "Smb: kdemain: starting" << endl; SmbProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/3aa6755fd59f18f72b67f93e44e1d9011b746142/kio_smb.cpp/buggy/kioslave/smbro/kio_smb.cpp
static void buildSupportedVectorFileFilter_(QString & fileFilters){ static QString myFileFilters = ""; // if we've already built the supported vector string, just return what // we've already built if ( ! myFileFilters.isEmpty() ) { fileFilters = myFileFilters; return; } // first get the GDAL driver manager OGRSFDriverRegistrar *driverRegistrar = OGRSFDriverRegistrar::GetRegistrar(); if (!driverRegistrar) { QMessageBox::warning(0,"OGR Driver Manger","unable to get OGRDriverManager"); return; // XXX good place to throw exception if we } // XXX decide to do exceptions // then iterate through all of the supported drivers, adding the // corresponding file filter OGRSFDriver *driver; // current driver QString driverName; // current driver name // Grind through all the drivers and their respective metadata. // We'll add a file filter for those drivers that have a file // extension defined for them; the others, welll, even though // theoreticaly we can open those files because there exists a // driver for them, the user will have to use the "All Files" to // open datasets with no explicitly defined file name extension.#ifdef QGISDEBUG std::cerr << "Driver count: " << driverRegistrar->GetDriverCount() << std::endl;#endif for (int i = 0; i < driverRegistrar->GetDriverCount(); ++i) { driver = driverRegistrar->GetDriver(i); Q_CHECK_PTR(driver); if (!driver) { qWarning("unable to get driver %d", i); continue; } driverName = driver->GetName(); if (driverName.startsWith("ESRI")) { myFileFilters += createFileFilter_("ESRI Shapefiles", "*.shp"); } else if (driverName.startsWith("UK")) { // XXX needs file filter extension } else if (driverName.startsWith("SDTS")) { myFileFilters += createFileFilter_( "Spatial Data Transfer Standard", "*catd.ddf" ); } else if (driverName.startsWith("TIGER")) { // XXX needs file filter extension } else if (driverName.startsWith("S57")) { // XXX needs file filter extension } else if (driverName.startsWith("MapInfo")) { myFileFilters += createFileFilter_("MapInfo", "*.mif *.tab"); // XXX needs file filter extension } else if (driverName.startsWith("DGN")) { // XXX needs file filter extension } else if (driverName.startsWith("VRT")) { // XXX needs file filter extension } else if (driverName.startsWith("AVCBin")) { // XXX needs file filter extension } else if (driverName.startsWith("REC")) { // XXX needs file filter extension } else if (driverName.startsWith("Memory")) { // XXX needs file filter extension } else if (driverName.startsWith("Jis")) { // XXX needs file filter extension } else if (driverName.startsWith("GML")) { // XXX not yet supported; post 0.1 release task // myFileFilters += createFileFilter_( "Geography Markup Language", // "*.gml" ); } else { // NOP, we don't know anything about the current driver // with regards to a proper file filter string } std::cout << myFileFilters << std::endl; } // each loaded GDAL driver // can't forget the default case myFileFilters += "All files (*.*)"; fileFilters = myFileFilters;} // buildSupportedVectorFileFilter_()
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/d00d0b2989843dff2a6f20f12ffe8a32322aa24a/qgisapp.cpp/buggy/src/qgisapp.cpp
std::cout << myFileFilters << std::endl;
static void buildSupportedVectorFileFilter_(QString & fileFilters){ static QString myFileFilters = ""; // if we've already built the supported vector string, just return what // we've already built if ( ! myFileFilters.isEmpty() ) { fileFilters = myFileFilters; return; } // first get the GDAL driver manager OGRSFDriverRegistrar *driverRegistrar = OGRSFDriverRegistrar::GetRegistrar(); if (!driverRegistrar) { QMessageBox::warning(0,"OGR Driver Manger","unable to get OGRDriverManager"); return; // XXX good place to throw exception if we } // XXX decide to do exceptions // then iterate through all of the supported drivers, adding the // corresponding file filter OGRSFDriver *driver; // current driver QString driverName; // current driver name // Grind through all the drivers and their respective metadata. // We'll add a file filter for those drivers that have a file // extension defined for them; the others, welll, even though // theoreticaly we can open those files because there exists a // driver for them, the user will have to use the "All Files" to // open datasets with no explicitly defined file name extension.#ifdef QGISDEBUG std::cerr << "Driver count: " << driverRegistrar->GetDriverCount() << std::endl;#endif for (int i = 0; i < driverRegistrar->GetDriverCount(); ++i) { driver = driverRegistrar->GetDriver(i); Q_CHECK_PTR(driver); if (!driver) { qWarning("unable to get driver %d", i); continue; } driverName = driver->GetName(); if (driverName.startsWith("ESRI")) { myFileFilters += createFileFilter_("ESRI Shapefiles", "*.shp"); } else if (driverName.startsWith("UK")) { // XXX needs file filter extension } else if (driverName.startsWith("SDTS")) { myFileFilters += createFileFilter_( "Spatial Data Transfer Standard", "*catd.ddf" ); } else if (driverName.startsWith("TIGER")) { // XXX needs file filter extension } else if (driverName.startsWith("S57")) { // XXX needs file filter extension } else if (driverName.startsWith("MapInfo")) { myFileFilters += createFileFilter_("MapInfo", "*.mif *.tab"); // XXX needs file filter extension } else if (driverName.startsWith("DGN")) { // XXX needs file filter extension } else if (driverName.startsWith("VRT")) { // XXX needs file filter extension } else if (driverName.startsWith("AVCBin")) { // XXX needs file filter extension } else if (driverName.startsWith("REC")) { // XXX needs file filter extension } else if (driverName.startsWith("Memory")) { // XXX needs file filter extension } else if (driverName.startsWith("Jis")) { // XXX needs file filter extension } else if (driverName.startsWith("GML")) { // XXX not yet supported; post 0.1 release task // myFileFilters += createFileFilter_( "Geography Markup Language", // "*.gml" ); } else { // NOP, we don't know anything about the current driver // with regards to a proper file filter string } std::cout << myFileFilters << std::endl; } // each loaded GDAL driver // can't forget the default case myFileFilters += "All files (*.*)"; fileFilters = myFileFilters;} // buildSupportedVectorFileFilter_()
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/d00d0b2989843dff2a6f20f12ffe8a32322aa24a/qgisapp.cpp/buggy/src/qgisapp.cpp
std::cout << myFileFilters << std::endl;
static void buildSupportedVectorFileFilter_(QString & fileFilters){ static QString myFileFilters = ""; // if we've already built the supported vector string, just return what // we've already built if ( ! myFileFilters.isEmpty() ) { fileFilters = myFileFilters; return; } // first get the GDAL driver manager OGRSFDriverRegistrar *driverRegistrar = OGRSFDriverRegistrar::GetRegistrar(); if (!driverRegistrar) { QMessageBox::warning(0,"OGR Driver Manger","unable to get OGRDriverManager"); return; // XXX good place to throw exception if we } // XXX decide to do exceptions // then iterate through all of the supported drivers, adding the // corresponding file filter OGRSFDriver *driver; // current driver QString driverName; // current driver name // Grind through all the drivers and their respective metadata. // We'll add a file filter for those drivers that have a file // extension defined for them; the others, welll, even though // theoreticaly we can open those files because there exists a // driver for them, the user will have to use the "All Files" to // open datasets with no explicitly defined file name extension.#ifdef QGISDEBUG std::cerr << "Driver count: " << driverRegistrar->GetDriverCount() << std::endl;#endif for (int i = 0; i < driverRegistrar->GetDriverCount(); ++i) { driver = driverRegistrar->GetDriver(i); Q_CHECK_PTR(driver); if (!driver) { qWarning("unable to get driver %d", i); continue; } driverName = driver->GetName(); if (driverName.startsWith("ESRI")) { myFileFilters += createFileFilter_("ESRI Shapefiles", "*.shp"); } else if (driverName.startsWith("UK")) { // XXX needs file filter extension } else if (driverName.startsWith("SDTS")) { myFileFilters += createFileFilter_( "Spatial Data Transfer Standard", "*catd.ddf" ); } else if (driverName.startsWith("TIGER")) { // XXX needs file filter extension } else if (driverName.startsWith("S57")) { // XXX needs file filter extension } else if (driverName.startsWith("MapInfo")) { myFileFilters += createFileFilter_("MapInfo", "*.mif *.tab"); // XXX needs file filter extension } else if (driverName.startsWith("DGN")) { // XXX needs file filter extension } else if (driverName.startsWith("VRT")) { // XXX needs file filter extension } else if (driverName.startsWith("AVCBin")) { // XXX needs file filter extension } else if (driverName.startsWith("REC")) { // XXX needs file filter extension } else if (driverName.startsWith("Memory")) { // XXX needs file filter extension } else if (driverName.startsWith("Jis")) { // XXX needs file filter extension } else if (driverName.startsWith("GML")) { // XXX not yet supported; post 0.1 release task // myFileFilters += createFileFilter_( "Geography Markup Language", // "*.gml" ); } else { // NOP, we don't know anything about the current driver // with regards to a proper file filter string } std::cout << myFileFilters << std::endl; } // each loaded GDAL driver // can't forget the default case myFileFilters += "All files (*.*)"; fileFilters = myFileFilters;} // buildSupportedVectorFileFilter_()
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/d00d0b2989843dff2a6f20f12ffe8a32322aa24a/qgisapp.cpp/buggy/src/qgisapp.cpp
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type);
void decode_state(bufferlist& bl, int& off) { bl.copy(off, sizeof(type), (char*)&type);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/4e4ab632f0b190f7001f3e014d71a2ba897ad5a6/Lock.h/buggy/ceph/mds/Lock.h
r.copy(off, sizeof(state), (char*)&state);
bl.copy(off, sizeof(state), (char*)&state);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/4e4ab632f0b190f7001f3e014d71a2ba897ad5a6/Lock.h/buggy/ceph/mds/Lock.h
r.copy(off, sizeof(mode), (char*)&mode);
bl.copy(off, sizeof(mode), (char*)&mode);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/4e4ab632f0b190f7001f3e014d71a2ba897ad5a6/Lock.h/buggy/ceph/mds/Lock.h
r.copy(off, sizeof(nread), (char*)&nread);
bl.copy(off, sizeof(nread), (char*)&nread);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/4e4ab632f0b190f7001f3e014d71a2ba897ad5a6/Lock.h/buggy/ceph/mds/Lock.h
r.copy(off, sizeof(nwrite), (char*)&nwrite);
bl.copy(off, sizeof(nwrite), (char*)&nwrite);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/4e4ab632f0b190f7001f3e014d71a2ba897ad5a6/Lock.h/buggy/ceph/mds/Lock.h
int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); }
_decode(gather_set, bl, off);
void decode_state(crope& r, int& off) { r.copy(off, sizeof(type), (char*)&type); off += sizeof(type); r.copy(off, sizeof(state), (char*)&state); off += sizeof(state); r.copy(off, sizeof(mode), (char*)&mode); off += sizeof(mode); r.copy(off, sizeof(nread), (char*)&nread); off += sizeof(nread); r.copy(off, sizeof(nwrite), (char*)&nwrite); off += sizeof(nwrite); //r.copy(off, sizeof(req_read), (char*)&req_read); //off += sizeof(req_read); //r.copy(off, sizeof(req_write), (char*)&req_write); //off += sizeof(req_write); int n; r.copy(off, sizeof(n), (char*)&n); off += sizeof(n); gather_set.clear(); int x; for (int i=0; i<n; i++) { r.copy(off, sizeof(x), (char*)&x); off += sizeof(x); gather_set.insert(x); } }
2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/4e4ab632f0b190f7001f3e014d71a2ba897ad5a6/Lock.h/buggy/ceph/mds/Lock.h
SysRes res = VG_(do_syscall1)(__NR_pipe, (UWord)fd);
SysRes res = VG_(do_syscall0)(__NR_pipe, (UWord)fd);
Int VG_(pipe) ( Int fd[2] ){ SysRes res = VG_(do_syscall1)(__NR_pipe, (UWord)fd); return res.isError ? -1 : 0;}
12192 /local/tlutelli/issta_data/temp/c/2005_temp/2005/12192/fe4746d6fba90584e880285ed6309b4d005a690a/m_libcfile.c/buggy/branches/aspacem/valgrind/coregrind/m_libcfile.c
for( int i = 0; i < fa.mFilename.size(); i++ ) { kdDebug() << (int)fa.mFilename[i] << endl; }
QDataStream& operator>> (QDataStream& s, sftpFileAttr& fa) { // XXX set all member variable to defaults // XXX Add some error checking in here in case // we get a bad sftp packet. fa.clear(); Q_UINT32 size; if( fa.mDirAttrs ) { s >> fa.mFilename; size = fa.mFilename.size(); fa.mFilename.resize(size+1); fa.mFilename[size] = 0; for( int i = 0; i < fa.mFilename.size(); i++ ) { kdDebug() << (int)fa.mFilename[i] << endl; } s >> fa.mLongname; size = fa.mLongname.size(); fa.mLongname.resize(size+1); fa.mLongname[size] = 0; //kdDebug() << ">> sftpfileattr filename (" << fa.mFilename.size() << ")= " << fa.mFilename << endl; } Q_UINT32 x; s >> fa.mFlags; // get flags if( fa.mFlags & SSH2_FILEXFER_ATTR_SIZE ) { // since we don't have a 64 bit int, ignore the top byte. // Very bad if we get a > 2^32 size s >> x; s >> x; fa.setFileSize(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_UIDGID ) { s >> x; fa.setUid(x); s >> x; fa.setGid(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_PERMISSIONS ) { s >> x; fa.setPermissions(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_ACMODTIME ) { s >> x; fa.setAtime(x); s >> x; fa.setMtime(x); } if( fa.mFlags & SSH2_FILEXFER_ATTR_EXTENDED ) { s >> x; fa.setExtendedCount(x); // XXX: Read in extensions from data stream here // s.readBytes(extendedtype).readBytes(extendeddata); } fa.getUserGroupNames(); return s;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/624c83586544906946ca706ebd3d074af76ffb31/sftpfileattr.cpp/clean/kioslave/sftp/sftpfileattr.cpp
case 'N':
case 'N': { c++; cstr = scan_number_code( c ); cplusplus = false; break; } #if 0
static char *scan_escape_direct( char *c, QCString& cstr ){ bool exoutputp; bool exskipescape; int i,j; bool cplusplus = true; // Should the c++ be done at the end of the function cstr = ""; intresult=0; switch (*c) { case 'e': cstr = "\\"; curpos++;break; // ### FIXME: it should be the current escape symbol case '0': // ### TODO Where in Unicode? (space of digit width) case '~': // non-breakable-space (resizeable!) case ' ': case '|': // half-non-breakable-space case '^': // quarter-non-breakable-space cstr = "&nbsp;"; curpos++; break; case '"': SKIPEOL; c--; break; // ### TODO \# like \" but does not ignore the end of line (groff(7)) case '$': { c++; cstr = scan_dollar_parameter( c ); cplusplus = false; break; } case 'z': { c++; if (*c=='\\') { c=scan_escape_direct( c+1, cstr ); c--; } else cstr = QCString( c, 1 ); break; } case 'k': c++; if (*c=='(') c+=2; // ### FIXME \k[REG] exists too case '!': case '%': case 'a': case 'd': case 'r': case 'u': case '\n': case '&': cstr = ""; break; case '(': case '[': case 'C': { // Do not go forward as scan_named_character needs the leading symbol cstr = scan_named_character( c ); cplusplus = false; break; } case '*': { c++; cstr = scan_named_string( c ); cplusplus = false; break; } case 'f': { c++; cstr = scan_named_font( c ); cplusplus = false; break; } case 's': // ### FIXME: many forms are missing c++; j=0;i=0; if (*c=='-') {j= -1; c++;} else if (*c=='+') {j=1; c++;} if (*c=='0') c++; else if (*c=='\\') { c++; c=scan_escape_direct( c, cstr ); i=intresult; if (!j) j=1; } else while (isdigit(*c) && (!i || (!j && i<4))) i=i*10+(*c++)-'0'; if (!j) { j=1; if (i) i=i-10; } if (!skip_escape) cstr=change_to_size(i*j); c--; break; case 'n': { c++; intresult = scan_number_register( c ); cplusplus = false; break; } case 'w': c++; i=*c; c++; exoutputp=output_possible; exskipescape=skip_escape; output_possible=false; skip_escape=true; j=0; while (*c!=i) { j++; if ( *c == escapesym ) c = scan_escape_direct( c+1, cstr); else c++; } output_possible=exoutputp; skip_escape=exskipescape; intresult=j; break; case 'l': cstr = "<HR>"; curpos=0; case 'b': case 'v': case 'x': case 'o': case 'L': case 'h': c++; i=*c; c++; exoutputp=output_possible; exskipescape=skip_escape; output_possible=0; skip_escape=true; while (*c != i) if (*c==escapesym) c=scan_escape_direct( c+1, cstr ); else c++; output_possible=exoutputp; skip_escape=exskipescape; break; case 'c': no_newline_output=1; break; case '{': newline_for_fun++; break; // Start conditional block case '}': if (newline_for_fun) newline_for_fun--; break; // End conditional block case 'p': cstr = "<BR>\n";curpos=0; break; case 't': cstr = "\t";curpos=(curpos+8)&0xfff8; break; case '<': cstr = "&lt;";curpos++; break; case '>': cstr = "&gt;";curpos++; break; case '\\': { if (single_escape) c--; else cstr="\\"; break; } case 'N': // ### FIXME should give an Unicode character &#9999; { if (*++c) c++; // c += 2 if (sscanf(c, "%d", &i) != 1) // (### FIXME ugly!) break; QCString temp; temp.sprintf( "%d", i ); // Skip over number (### FIXME ugly!) c += temp.length(); switch(i) { case 8: cstr = "\t"; curpos=(curpos+8)&0xfff8; break; case 34: cstr = "&quot;"; curpos++; break; default: cstr = char( i ); curpos++; break; } break; } case '\'': cstr = "&acute;";curpos++; break; // groff(7) ### TODO verify case '`': cstr = "`";curpos++; break; // groff(7) case '-': cstr = "-";curpos++; break; // groff(7) case '.': cstr = ".";curpos++; break; // groff(7) default: cstr = *c; curpos++; break; } if (cplusplus) c++; return c;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a2a0d621d2afd22ae7cf2ad733a2ce62a96b2010/man2html.cpp/buggy/kioslave/man/man2html.cpp
#endif
static char *scan_escape_direct( char *c, QCString& cstr ){ bool exoutputp; bool exskipescape; int i,j; bool cplusplus = true; // Should the c++ be done at the end of the function cstr = ""; intresult=0; switch (*c) { case 'e': cstr = "\\"; curpos++;break; // ### FIXME: it should be the current escape symbol case '0': // ### TODO Where in Unicode? (space of digit width) case '~': // non-breakable-space (resizeable!) case ' ': case '|': // half-non-breakable-space case '^': // quarter-non-breakable-space cstr = "&nbsp;"; curpos++; break; case '"': SKIPEOL; c--; break; // ### TODO \# like \" but does not ignore the end of line (groff(7)) case '$': { c++; cstr = scan_dollar_parameter( c ); cplusplus = false; break; } case 'z': { c++; if (*c=='\\') { c=scan_escape_direct( c+1, cstr ); c--; } else cstr = QCString( c, 1 ); break; } case 'k': c++; if (*c=='(') c+=2; // ### FIXME \k[REG] exists too case '!': case '%': case 'a': case 'd': case 'r': case 'u': case '\n': case '&': cstr = ""; break; case '(': case '[': case 'C': { // Do not go forward as scan_named_character needs the leading symbol cstr = scan_named_character( c ); cplusplus = false; break; } case '*': { c++; cstr = scan_named_string( c ); cplusplus = false; break; } case 'f': { c++; cstr = scan_named_font( c ); cplusplus = false; break; } case 's': // ### FIXME: many forms are missing c++; j=0;i=0; if (*c=='-') {j= -1; c++;} else if (*c=='+') {j=1; c++;} if (*c=='0') c++; else if (*c=='\\') { c++; c=scan_escape_direct( c, cstr ); i=intresult; if (!j) j=1; } else while (isdigit(*c) && (!i || (!j && i<4))) i=i*10+(*c++)-'0'; if (!j) { j=1; if (i) i=i-10; } if (!skip_escape) cstr=change_to_size(i*j); c--; break; case 'n': { c++; intresult = scan_number_register( c ); cplusplus = false; break; } case 'w': c++; i=*c; c++; exoutputp=output_possible; exskipescape=skip_escape; output_possible=false; skip_escape=true; j=0; while (*c!=i) { j++; if ( *c == escapesym ) c = scan_escape_direct( c+1, cstr); else c++; } output_possible=exoutputp; skip_escape=exskipescape; intresult=j; break; case 'l': cstr = "<HR>"; curpos=0; case 'b': case 'v': case 'x': case 'o': case 'L': case 'h': c++; i=*c; c++; exoutputp=output_possible; exskipescape=skip_escape; output_possible=0; skip_escape=true; while (*c != i) if (*c==escapesym) c=scan_escape_direct( c+1, cstr ); else c++; output_possible=exoutputp; skip_escape=exskipescape; break; case 'c': no_newline_output=1; break; case '{': newline_for_fun++; break; // Start conditional block case '}': if (newline_for_fun) newline_for_fun--; break; // End conditional block case 'p': cstr = "<BR>\n";curpos=0; break; case 't': cstr = "\t";curpos=(curpos+8)&0xfff8; break; case '<': cstr = "&lt;";curpos++; break; case '>': cstr = "&gt;";curpos++; break; case '\\': { if (single_escape) c--; else cstr="\\"; break; } case 'N': // ### FIXME should give an Unicode character &#9999; { if (*++c) c++; // c += 2 if (sscanf(c, "%d", &i) != 1) // (### FIXME ugly!) break; QCString temp; temp.sprintf( "%d", i ); // Skip over number (### FIXME ugly!) c += temp.length(); switch(i) { case 8: cstr = "\t"; curpos=(curpos+8)&0xfff8; break; case 34: cstr = "&quot;"; curpos++; break; default: cstr = char( i ); curpos++; break; } break; } case '\'': cstr = "&acute;";curpos++; break; // groff(7) ### TODO verify case '`': cstr = "`";curpos++; break; // groff(7) case '-': cstr = "-";curpos++; break; // groff(7) case '.': cstr = ".";curpos++; break; // groff(7) default: cstr = *c; curpos++; break; } if (cplusplus) c++; return c;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a2a0d621d2afd22ae7cf2ad733a2ce62a96b2010/man2html.cpp/buggy/kioslave/man/man2html.cpp
"rr", "rnn", "aln", "shift", "while", 0 };
"rr", "rnn", "aln", "shift", "while", "do", 0 };
static int get_request(char *req, int len){ static const char *requests[] = { "ab", "di", "ds", "as", "br", "c2", "cc", "ce", "ec", "eo", "ex", "fc", "fi", "ft", "el", "ie", "if", "ig", "nf", "ps", "sp", "so", "ta", "ti", "tm", "B", "I", "Fd", "Fn", "Fo", "Fc", "OP", "Ft", "Fa", "BR", "BI", "IB", "IR", "RB", "RI", "DT", "IP", "TP", "IX", "P", "LP", "PP", "HP", "PD", "Rs", "RS", "Re", "RE", "SB", "SM", "Ss", "SS", "Sh", "SH", "Sx", "TS", "Dt", "TH", "TX", "rm", "rn", "nx", "in", "nr", "am", "de", "Bl", "El", "It", "Bk", "Ek", "Dd", "Os", "Bt", "At", "Fx", "Nx", "Ox", "Bx", "Ux", "Dl", "Bd", "Ed", "Be", "Xr", "Fl", "Pa", "Pf", "Pp", "Dq", "Op", "Oo", "Oc", "Pq", "Ql", "Sq", "Ar", "Ad", "Em", "Va", "Xc", "Nd", "Nm", "Cd", "Cm", "Ic", "Ms", "Or", "Sy", "Dv", "Ev", "Fr", "Li", "No", "Ns", "Tn", "nN", "%A", "%D", "%N", "%O", "%P", "%Q", "%V", "%B", "%J", "%R", "%T", "An", "Aq", "Bq", "Qq", "UR", "UE", "UN", "troff", "nroff", "als", "rr", "rnn", "aln", "shift", "while", 0 }; int r = 0; while (requests[r] && qstrncmp(req, requests[r], len)) r++; return requests[r] ? r : REQ_UNKNOWN;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a2a0d621d2afd22ae7cf2ad733a2ce62a96b2010/man2html.cpp/buggy/kioslave/man/man2html.cpp
const int max_wordlist=100;
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a2a0d621d2afd22ae7cf2ad733a2ce62a96b2010/man2html.cpp/buggy/kioslave/man/man2html.cpp
int j; if (c[1]=='\n') j=1; else j=2;
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a2a0d621d2afd22ae7cf2ad733a2ce62a96b2010/man2html.cpp/buggy/kioslave/man/man2html.cpp
j = nlen;
int j = nlen;
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a2a0d621d2afd22ae7cf2ad733a2ce62a96b2010/man2html.cpp/buggy/kioslave/man/man2html.cpp
delete [] line;
delete [] line;
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a2a0d621d2afd22ae7cf2ad733a2ce62a96b2010/man2html.cpp/buggy/kioslave/man/man2html.cpp
out_html(set_font("R"));
out_html(set_font("P"));
static char *scan_request(char *c){ // mdoc(7) stuff static bool mandoc_synopsis=false; /* True if we are in the synopsis section */ static bool mandoc_command=false; /* True if this is mdoc(7) page */ static int mandoc_bd_options; /* Only copes with non-nested Bd's */ static int function_argument=0; // Number of function argument (.Fo, .Fa, .Fc) // man(7) stuff static bool ur_ignore=false; // Has .UR a parameter : (for .UE to know if or not to write </a>) int i=0; bool mode=false; char *h=0; const int max_wordlist=100; char *wordlist[max_wordlist]; int words; char *sl; while (*c==' ' || *c=='\t') c++; // Spaces or tabs allowed between control character and request if (c[0]=='\n') return c+1; if (c[0]==escapesym) { /* some pages use .\" .\$1 .\} */ /* .\$1 is too difficult/stuppid */ if (c[1]=='$') { kdDebug(7107) << "Found .\\$" << endl; c=skip_till_newline(c); // ### TODO } else c = scan_escape(c+1); } else { int j; if (c[1]=='\n') j=1; else j=2; // ### TODO: remove, as i is over-written later int nlen = 0; QCString macroName; while (c[nlen] && (c[nlen] != ' ') && (c[nlen] != '\t') && (c[nlen] != '\n') && (c[nlen] != escapesym)) { macroName+=c[nlen]; nlen++; } j = nlen; while (c[j] && c[j]==' ' || c[j]=='\t') j++; /* search macro database of self-defined macros */ QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(macroName); if (it!=s_stringDefinitionMap.end()) { kdDebug(7107) << "CALLING MACRO: " << macroName << endl; const QCString oldDollarZero = s_dollarZero; // Previous value of $0 s_dollarZero = macroName; sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; for (i=1;i<words; i++) wordlist[i][-1]='\0'; for (i=0; i<words; i++) { char *h=NULL; if (mandoc_command) scan_troff_mandoc(wordlist[i],1,&h); else scan_troff(wordlist[i],1,&h); wordlist[i] = qstrdup(h); delete [] h; } for ( i=words; i<max_wordlist; i++ ) wordlist[i]=NULL; if ( !(*it).m_output.isEmpty() ) { //kdDebug(7107) << "Macro content is: " << endl << (*it).m_output << endl; const unsigned int length = (*it).m_output.length(); char* work = new char [length+2]; work[0] = '\n'; // The macro must start after an end of line to allow a request on first line qstrncpy(work+1,(*it).m_output.data(),length+1); const QValueList<char*> oldArgumentList( s_argumentList ); s_argumentList.clear(); for ( i = 0 ; i < max_wordlist; i++ ) { if (!wordlist[i]) break; s_argumentList.push_back( wordlist[i] ); } const int onff=newline_for_fun; if (mandoc_command) scan_troff_mandoc( work + 1, 0, NULL ); else scan_troff( work + 1, 0, NULL); delete[] work; newline_for_fun=onff; s_argumentList = oldArgumentList; } for (i=0; i<words; i++) delete [] wordlist[i]; *sl='\n'; s_dollarZero = oldDollarZero; kdDebug(7107) << "ENDING MACRO: " << macroName << endl; } else { kdDebug(7107) << "REQUEST: " << macroName << endl; switch (int request = get_request(c, nlen)) { case REQ_ab: // groff(7) "ABort" { h=c+j; while (*h && *h !='\n') h++; *h='\0'; if (scaninbuff && buffpos) { buffer[buffpos]='\0'; kdDebug(7107) << "ABORT: " << buffer << endl; } // ### TODO find a way to display it to the user kdDebug(7107) << "Aborting: .ab " << (c+j) << endl; return 0; break; } case REQ_An: // mdoc(7) "Author Name" { c+=j; c=scan_troff_mandoc(c,1,0); break; } case REQ_di: // groff(7) "end current DIversion" { kdDebug(7107) << "Start .di" << endl; c+=j; if (*c=='\n') { ++c; break; } const QCString name ( scan_identifier( c ) ); while (*c && *c!='\n') c++; c++; h=c; while (*c && qstrncmp(c,".di",3)) while (*c && *c++!='\n'); *c='\0'; char* result=0; scan_troff(h,0,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { (*it).m_length=0; (*it).m_output=result; } delete[] result; if (*c) *c='.'; c=skip_till_newline(c); kdDebug(7107) << "end .di" << endl; break; } case REQ_ds: // groff(7) "Define String variable" mode=true; case REQ_as: // groff (7) "Append String variable" { kdDebug(7107) << "start .ds/.as" << endl; int oldcurpos=curpos; c+=j; const QCString name( scan_identifier( c) ); if ( name.isEmpty() ) break; while (*c && isspace(*c)) c++; if (*c && *c=='"') c++; single_escape=true; curpos=0; char* result=0; c=scan_troff(c,1,&result); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=curpos; def.m_output=result; s_stringDefinitionMap.insert(name,def); } else { if (mode) { // .ds Defining String (*it).m_length=curpos; (*it).m_output=result; } else { // .as Appending String (*it).m_length+=curpos; (*it).m_output+=result; } } delete[] result; single_escape=false; curpos=oldcurpos; kdDebug(7107) << "end .ds/.as" << endl; break; } case REQ_br: // groff(7) "line BReak" { if (still_dd) out_html("<DD>"); // ### VERIFY (does not look like generating good HTML) else out_html("<BR>\n"); curpos=0; c=c+j; if (c[0]==escapesym) c=scan_escape(c+1); c=skip_till_newline(c); break; } case REQ_c2: // groff(7) "reset non-break Control character" (2 means non-break) { c=c+j; if (*c!='\n') nobreaksym=*c; else nobreaksym='\''; c=skip_till_newline(c); break; } case REQ_cc: // groff(7) "reset Control Character" { c=c+j; if (*c!='\n') controlsym=*c; else controlsym='.'; c=skip_till_newline(c); break; } case REQ_ce: // groff (7) "CEnter" { c=c+j; if (*c=='\n') i=1; else { i=0; while ('0'<=*c && *c<='9') { i=i*10+*c-'0'; c++; } } c=skip_till_newline(c); /* center next i lines */ if (i>0) { out_html("<CENTER>\n"); while (i && *c) { char *line=NULL; c=scan_troff(c,1, &line); if (line && qstrncmp(line, "<BR>", 4)) { out_html(line); out_html("<BR>\n"); delete [] line; i--; } } out_html("</CENTER>\n"); curpos=0; } break; } case REQ_ec: // groff(7) "reset Escape Character" { c=c+j; if (*c!='\n') escapesym=*c; else escapesym='\\'; break; c=skip_till_newline(c); } case REQ_eo: // groff(7) "turn Escape character Off" { escapesym='\0'; c=skip_till_newline(c); break; } case REQ_ex: // groff(7) "EXit" { return 0; break; } case REQ_fc: // groff(7) "set Field and pad Character" { c=c+j; if (*c=='\n') fieldsym=padsym='\0'; else { fieldsym=c[0]; padsym=c[1]; } c=skip_till_newline(c); break; } case REQ_fi: // groff(7) "FIll" { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_ft: // groff(7) "previous FonT" { c=c+j; if (*c=='\n') out_html(set_font("R"));#if 0 else { // ### FIXME if (*c==escapesym) { int fn; c=scan_expression(c, &fn); c--; out_html(set_font(fn)); } else { out_html(set_font(*c)); c++; } }#endif c=skip_till_newline(c); break; } case REQ_el: // groff(7) "ELse" { int ifelseval = s_ifelseval.pop(); /* .el anything : else part of if else */ if (ifelseval) { c=c+j; c[-1]='\n'; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c+j); break; } case REQ_ie: // groff(7) "If with Else" /* .ie c anything : then part of if else */ case REQ_if: // groff(7) "IF" { /* .if c anything * .if !c anything * .if N anything * .if !N anything * .if 'string1'string2' anything * .if !'string1'string2' anything */ c=c+j; c=scan_expression(c, &i); if (request == REQ_ie) { int ifelseval=!i; s_ifelseval.push( ifelseval ); } if (i) { *c='\n'; c++; c=scan_troff(c,1,NULL); } else c=skip_till_newline(c); break; } case REQ_ig: // groff(7) "IGnore" { const char *endwith="..\n"; i=3; c=c+j; if (*c!='\n' && *c != '\\') { /* Not newline or comment */ endwith=c-1;i=1; c[-1]='.'; while (*c && *c!='\n') c++,i++; } c++; while (*c && qstrncmp(c,endwith,i)) while (*c++!='\n'); while (*c && *c++!='\n'); break; } case REQ_nf: // groff(7) "No Filling" { if (fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; c=skip_till_newline(c); break; } case REQ_ps: // groff(7) "previous Point Size" { c=c+j; if (*c=='\n') out_html(change_to_size('0')); else { j=0; i=0; if (*c=='-') { j= -1; c++; } else if (*c=='+') j=1;c++; c=scan_expression(c, &i); if (!j) { j=1; if (i>5) i=i-10; } out_html(change_to_size(i*j)); } c=skip_till_newline(c); break; } case REQ_sp: // groff(7) "SKip one line" { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_so: // groff(7) "Include SOurce file" { char *buf; char *name=NULL; curpos=0; c=c+j; if (*c=='/') h=c; else { h=c-3; h[0]='.'; h[1]='.'; h[2]='/'; } while (*c!='\n') c++; *c='\0'; scan_troff(h,1, &name); if (name[3]=='/') h=name+3; else h=name; /* this works alright, except for section 3 */ buf=read_man_page(h); if (!buf) { kdDebug(7107) << "Unable to open or read file: .so " << (h) << endl; out_html("<BLOCKQUOTE>" "man2html: unable to open or read file.\n"); out_html(h); out_html("</BLOCKQUOTE>\n"); } else scan_troff(buf+1,0,NULL); delete [] buf; delete [] name; *c++='\n'; break; } case REQ_ta: // gorff(7) "set TAbulators" { c=c+j; j=0; while (*c!='\n') { sl=scan_expression(c, &tabstops[j]); if (j>0 && (*c=='-' || *c=='+')) tabstops[j]+=tabstops[j-1]; c=sl; while (*c==' ' || *c=='\t') c++; j++; } maxtstop=j; curpos=0; break; } case REQ_ti: // groff(7) "Temporary Indent" { /*while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else itemdepth--; }*/ out_html("<BR>\n"); c=c+j; c=scan_expression(c, &j); for (i=0; i<j; i++) out_html("&nbsp;"); curpos=j; c=skip_till_newline(c); break; } case REQ_tm: // groff(7) "TerMinal" ### TODO: what are useful uses for it { c=c+j; h=c; while (*c!='\n') c++; *c='\0'; kdDebug(7107) << ".tm " << (h) << endl; *c='\n'; break; } case REQ_B: // man(7) "Bold" mode=1; case REQ_I: // man(7) "Italic" { /* parse one line in a certain font */ out_html( set_font( mode?"B":"I" ) ); fill_words(c, wordlist, &words, false, 0); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fd: // mdoc(7) "Function Definition" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } if (mandoc_synopsis) { out_html(");"); out_html("<br>"); }; out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fn: // mdoc(7) for "Function calls" ### FIXME { // brackets and commas have to be inserted automatically char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); if (!words) { out_html(" ()"); } else { for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } else if (i<words-1) out_html(", "); } out_html(")"); } out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fo: // mdoc(7) "Function definition Opening" { char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; char *eol=strchr(c,'\n'); char *semicolon=strchr(c,';'); if ((semicolon!=0) && (semicolon<eol)) *semicolon=' '; sl=fill_words(c, wordlist, &words, true, &c); // Normally a .Fo has only one parameter for (i=0; i<words; i++) { wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); if (i==0) { out_html(" ("); } // ### TODO What should happen if there is more than one argument // else if (i<words-1) out_html(", "); } function_argument=1; // Must be > 0 out_html(set_font("R")); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_Fc:// mdoc(7) "Function definition Close" { // .Fc has no parameter c+=j; c=skip_till_newline(c); char font[2]; font[0] = 'B'; font[1] = 'R'; // ### FIXME out_html(set_font(font[i&1])); out_html(")"); out_html(set_font("R")); if (mandoc_synopsis) out_html("<br>"); out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; function_argument=0; // Reset the count variable break; } case REQ_Fa: // mdoc(7) "Function definition argument" { char font[2] ; font[0] = 'B'; font[1] = 'R'; // ### FIXME c+=j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font(font[i&1])); // function_argument==0 means that we had no .Fo before, e.g. in mdoc.samples(7) if (function_argument > 1) { out_html(", "); curpos+=2; function_argument++; } else if (function_argument==1) { // We are only at the first parameter function_argument++; } for (i=0; i<words; i++) { wordlist[i][-1]=' '; scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (!fillout) curpos=0; else curpos++; break; } case REQ_OP: /* groff manpages use this construction */ /* .OP a b : [ <B>a</B> <I>b</I> ] */ mode=true; c[0]='B'; c[1]='I'; out_html(set_font("R")); out_html("["); curpos++; // Do not break! case REQ_Ft: //perhaps "Function return type" case REQ_BR: case REQ_BI: case REQ_IB: case REQ_IR: case REQ_RB: case REQ_RI: { // ### VERIFY bool inFMode=(c[0]=='F'); if (inFMode) { c[0]='B'; c[1]='I'; }; char font[2] ; font[0] = c[0]; font[1] = c[1]; c=c+j; if (*c=='\n') c++; sl=fill_words(c, wordlist, &words, true, &c); /* .BR name (section) * indicates a link. It will be added in the output routine. */ for (i=0; i<words; i++) { if ((mode) || (inFMode)) { out_html(" "); curpos++; } wordlist[i][-1]=' '; out_html(set_font(font[i&1])); scan_troff(wordlist[i],1,NULL); } out_html(set_font("R")); if (mode) { out_html(" ]"); curpos++; } out_html(NEWLINE); if (!fillout) curpos=0; else curpos++; break; } case REQ_DT: // man(7) "Default Tabulators" { for (j=0;j<20; j++) tabstops[j]=(j+1)*8; maxtstop=20; c=skip_till_newline(c); break; } case REQ_IP: // man(7) "Ident Paragraph" { sl=fill_words(c+j, wordlist, &words, true, &c); if (!dl_set[itemdepth]) { out_html("<DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); if (words) scan_troff(wordlist[0], 1,NULL); out_html("<DD>"); curpos=0; break; } case REQ_TP: // man(7) "hanging Tag Paragraph" { if (!dl_set[itemdepth]) { out_html("<br><br><DL>\n"); dl_set[itemdepth]=1; } out_html("<DT>"); c=skip_till_newline(c); /* somewhere a definition ends with '.TP' */ if (!*c) still_dd=true; else { c=scan_troff(c,1,NULL); out_html("<DD>"); } curpos=0; break; } case REQ_IX: // "INdex" ### TODO: where is it defined? { /* general index */ c=skip_till_newline(c); break; } case REQ_P: // man(7) "Paragraph" case REQ_LP:// man(7) "Paragraph" case REQ_PP:// man(7) "Paragraph; reset Prevailing indent" { if (dl_set[itemdepth]) { out_html("</DL>\n"); dl_set[itemdepth]=0; } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_HP: // man(7) "Hanging indent Paragraph" { if (!dl_set[itemdepth]) { out_html("<DL>"); dl_set[itemdepth]=1; } out_html("<DT>\n"); still_dd=true; c=skip_till_newline(c); curpos=0; break; } case REQ_PD: // man(7) "Paragraph Distance" { c=skip_till_newline(c); break; } case REQ_Rs: // mdoc(7) "Relative margin Start" case REQ_RS: // man(7) "Relative margin Start" { sl=fill_words(c+j, wordlist, &words, true, 0); j=1; if (words>0) scan_expression(wordlist[0], &j); if (j>=0) { itemdepth++; dl_set[itemdepth]=0; out_html("<DL><DT><DD>"); c=skip_till_newline(c); curpos=0; break; } } case REQ_Re: // mdoc(7) "Relative margin End" case REQ_RE: // man(7) "Relative margin End" { if (itemdepth > 0) { if (dl_set[itemdepth]) out_html("</DL>"); out_html("</DL>\n"); itemdepth--; } c=skip_till_newline(c); curpos=0; break; } case REQ_SB: // man(7) "Small; Bold" { out_html(set_font("B")); out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c+j, 1, NULL); out_html("</small>"); out_html(set_font("R")); break; } case REQ_SM: // man(7) "SMall" { c=c+j; if (*c=='\n') c++; out_html("<small>"); trans_char(c,'"','\a'); // ### VERIFY c=scan_troff(c,1,NULL); out_html("</small>"); break; } case REQ_Ss: // mdoc(7) "Sub Section" mandoc_command = 1; case REQ_SS: // mdoc(7) "Sub Section" mode=true; case REQ_Sh: // mdoc(7) "Sub Header" /* hack for fallthru from above */ mandoc_command = !mode || mandoc_command; case REQ_SH: // man(7) "Sub Header" { c=c+j; if (*c=='\n') c++; while (itemdepth || dl_set[itemdepth]) { out_html("</DL>\n"); if (dl_set[itemdepth]) dl_set[itemdepth]=0; else if (itemdepth > 0) itemdepth--; } out_html(set_font("R")); out_html(change_to_size(0)); if (!fillout) { fillout=1; out_html("</PRE>"); } trans_char(c,'"', '\a'); if (section) { out_html("</div>\n"); section=0; } if (mode) out_html("\n<H3>"); else out_html("\n<H2>"); mandoc_synopsis = qstrncmp(c, "SYNOPSIS", 8) == 0; c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL); if (mode) out_html("</H3>\n"); else out_html("</H2>\n"); out_html("<div>\n"); section=1; curpos=0; break; } case REQ_Sx: // mdoc(7) { // reference to a section header out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_TS: // ### TODO where is it defined? (tbl?) { c=scan_table(c); break; } case REQ_Dt: /* mdoc(7) */ mandoc_command = true; case REQ_TH: // man(7) "Title Header" { if (!output_possible) { sl = fill_words(c+j, wordlist, &words, true, &c); // ### TODO: the page should be displayed even if it is "anonymous" (words==0) if (words>=1) { for (i=1; i<words; i++) wordlist[i][-1]='\0'; *sl='\0'; for (i=0; i<words; i++) { if (wordlist[i][0] == '\007') wordlist[i]++; if (wordlist[i][qstrlen(wordlist[i])-1] == '\007') wordlist[i][qstrlen(wordlist[i])-1] = 0; } output_possible=true; out_html( DOCTYPE"<HTML>\n<HEAD>\n");#ifdef SIMPLE_MAN2HTML // Most English man pages are in ISO-8859-1 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");#else // kio_man transforms from local to UTF-8 out_html("<meta http-equiv=\"Content-Type\" content=\"text/html; charset="); out_html(QTextCodec::codecForLocale()->mimeName()); out_html("\">\n");#endif out_html("<TITLE>"); out_html(scan_troff(wordlist[0], 0, NULL)); out_html( " Manpage</TITLE>\n"); out_html( "<link rel=\"stylesheet\" href=\""); out_html(htmlPath); out_html("/kde-default.css\" type=\"text/css\">\n" ); out_html( "<meta name=\"ROFF Type\" content=\""); if (mandoc_command) out_html("mdoc"); else out_html("man"); out_html("\">\n"); out_html( "</HEAD>\n\n" ); out_html("<BODY BGCOLOR=\"#FFFFFF\">\n\n" ); out_html("<div style=\"background-image: url("); out_html(cssPath); out_html("/top-middle.png); width: 100%; height: 131pt;\">\n" ); out_html("<div style=\"position: absolute; right: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-right-konqueror.png\" style=\"margin: 0pt\" alt=\"Top right\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; left: 0pt;\">\n"); out_html("<img src=\""); out_html(htmlPath); out_html("/top-left.png\" style=\"margin: 0pt\" alt=\"Top left\">\n"); out_html("</div>\n"); out_html("<div style=\"position: absolute; top: 25pt; right: 100pt; text-align: right; font-size: xx-large; font-weight: bold; text-shadow: #fff 0pt 0pt 5pt; color: #444\">\n"); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html("</div>\n"); out_html("</div>\n"); out_html("<div style=\"margin-left: 5em; margin-right: 5em;\">\n"); out_html("<h1>" ); out_html( scan_troff(wordlist[0], 0, NULL ) ); out_html( "</h1>\n" ); if (words>1) { out_html("Section: " ); if (!mandoc_command && words>4) out_html(scan_troff(wordlist[4], 0, NULL) ); else out_html(section_name(wordlist[1])); out_html(" ("); out_html(scan_troff(wordlist[1], 0, NULL)); out_html(")\n"); } else { out_html("Section not specified"); } *sl='\n'; } } else { kdWarning(7107) << ".TH found but output not possible" << endl; c=skip_till_newline(c); } curpos=0; break; } case REQ_TX: // mdoc(7) { sl=fill_words(c+j, wordlist, &words, true, &c); *sl='\0'; out_html(set_font("I")); if (words>1) wordlist[1][-1]='\0'; const char *c2=lookup_abbrev(wordlist[0]); curpos+=qstrlen(c2); out_html(c2); out_html(set_font("R")); if (words>1) out_html(wordlist[1]); *sl='\n'; break; } case REQ_rm: // groff(7) "ReMove" /* .rm xx : Remove request, macro or string */ mode=true; case REQ_rn: // groff(7) "ReName" /* .rn xx yy : Rename request, macro or string xx to yy */ { kdDebug(7107) << "start .rm/.rn" << endl; c+=j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } QCString name2; if ( !mode ) { while (*c && isspace(*c) && *c!='\n') ++c; name2 = scan_identifier( c ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to rename: " << endl; break; } } c=skip_till_newline(c); QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to rename or remove: " << name << endl; } else { if (mode) { // .rm ReMove s_stringDefinitionMap.remove(name); // ### QT4: removeAll } else { // .rn ReName StringDefinition def=(*it); s_stringDefinitionMap.remove(name); // ### QT4: removeAll s_stringDefinitionMap.insert(name2,def); } } kdDebug(7107) << "end .rm/.rn" << endl; break; } case REQ_nx: // ### TODO in man(7) it is "No filling", not "next file" /* .nx filename : next file. */ case REQ_in: // groff(7) "INdent" { /* .in +-N : Indent */ c=skip_till_newline(c); break; } case REQ_nr: // groff(7) "Number Register" { kdDebug(7107) << "start .nr" << endl; c += j; const QCString name( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty name for register variable" << endl; break; } while ( *c && ( *c==' ' || *c=='\t' ) ) c++; int sign = 0; if ( *c && ( *c == '+' || *c == '-' ) ) { if ( *c == '+' ) sign = 1; else if ( *c == '-' ) sign = -1; } int value = 0; int increment = 0; c=scan_expression( c, &value ); if ( *c && *c!='\n') { while ( *c && ( *c==' ' || *c=='\t' ) ) c++; c=scan_expression( c, &increment ); } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { if ( sign < 1 ) value = -value; NumberDefinition def( value, increment ); s_numberDefinitionMap.insert( name, def ); } else { if ( sign > 0 ) (*it).m_value += value; else if ( sign < 0 ) (*it).m_value += - value; else (*it).m_value = value; (*it).m_increment = increment; } kdDebug(7107) << "end .nr" << endl; break; } case REQ_am: // groff(7) "Append Macro" /* .am xx yy : append to a macro. */ /* define or handle as .ig yy */ mode=true; case REQ_de: // groff(7) "DEfine macro" /* .de xx yy : define or redefine macro xx; end at .yy (..) */ /* define or handle as .ig yy */ { kdDebug(7107) << "Start .am/.de" << endl; c+=j; char *next_line; sl = fill_words(c, wordlist, &words, true, &next_line); char *nameStart = wordlist[0]; c = nameStart; while (*c && (*c != ' ') && (*c != '\n')) c++; *c = '\0'; const QCString name(nameStart); QCString endmacro; if (words == 1) { endmacro=".."; } else { endmacro='.'; c = wordlist[1]; while (*c && (*c != ' ') && (*c != '\n')) endmacro+=*c++; } c = next_line; sl=c; const int length=qstrlen(endmacro); while (*c && qstrncmp(c,endmacro,length)) c=skip_till_newline(c); QCString macro; while (sl!=c) { if (sl[0]=='\\' && sl[1]=='\\') { macro+='\\'; sl++; } else macro+=*sl; sl++; } QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name); if (it==s_stringDefinitionMap.end()) { StringDefinition def; def.m_length=0; def.m_output=macro; s_stringDefinitionMap.insert(name,def); } else if (mode) { // .am Append Macro (*it).m_length=0; // It could be formerly a string if ((*it).m_output.right(1)!='\n') (*it).m_output+='\n'; (*it).m_output+=macro; } else { // .de DEfine macro (*it).m_length=0; // It could be formerly a string (*it).m_output=macro; } c=skip_till_newline(c); kdDebug(7107) << "End .am/.de" << endl; break; } case REQ_Bl: // mdoc(7) "Begin List" { char list_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (dl_set[itemdepth]) /* These things can nest. */ itemdepth++; if (nl) { /* Parse list options */ strlimitcpy(list_options, c, nl - c, MED_STR_MAX); } if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */ dl_set[itemdepth] = BL_BULLET_LIST; out_html("<UL>\n"); } else if (strstr(list_options, "-enum")) { /* HTML Ordered List */ dl_set[itemdepth] = BL_ENUM_LIST; out_html("<OL>\n"); } else { /* HTML Descriptive List */ dl_set[itemdepth] = BL_DESC_LIST; out_html("<DL>\n"); } if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_El: // mdoc(7) "End List" { c=c+j; if (dl_set[itemdepth] & BL_DESC_LIST) out_html("</DL>\n"); else if (dl_set[itemdepth] & BL_BULLET_LIST) out_html("</UL>\n"); else if (dl_set[itemdepth] & BL_ENUM_LIST) out_html("</OL>\n"); dl_set[itemdepth]=0; if (itemdepth > 0) itemdepth--; if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_It: // mdoc(7) "list ITem" { c=c+j; if (qstrncmp(c, "Xo", 2) == 0 && isspace(*(c+2))) c = skip_till_newline(c); if (dl_set[itemdepth] & BL_DESC_LIST) { out_html("<DT>"); out_html(set_font("B")); if (*c=='\n') { /* Don't allow embedded comms after a newline */ c++; c=scan_troff(c,1,NULL); } else { /* Do allow embedded comms on the same line. */ c=scan_troff_mandoc(c,1,NULL); } out_html(set_font("R")); out_html(NEWLINE); out_html("<DD>"); } else if (dl_set[itemdepth] & (BL_BULLET_LIST | BL_ENUM_LIST)) { out_html("<LI>"); c=scan_troff_mandoc(c,1,NULL); out_html(NEWLINE); } if (fillout) curpos++; else curpos=0; break; } case REQ_Bk: /* mdoc(7) */ case REQ_Ek: /* mdoc(7) */ case REQ_Dd: /* mdoc(7) */ case REQ_Os: // mdoc(7) "Operating System" { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Bt: // mdoc(7) "Beta Test" { trans_char(c,'"','\a'); c=c+j; out_html(" is currently in beta test."); if (fillout) curpos++; else curpos=0; break; } case REQ_At: /* mdoc(7) */ case REQ_Fx: /* mdoc(7) */ case REQ_Nx: /* mdoc(7) */ case REQ_Ox: /* mdoc(7) */ case REQ_Bx: /* mdoc(7) */ case REQ_Ux: /* mdoc(7) */ { bool parsable=true; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; if (request==REQ_At) { out_html("AT&amp;T UNIX "); parsable=false; } else if (request==REQ_Fx) { out_html("FreeBSD "); parsable=false; } else if (request==REQ_Nx) out_html("NetBSD "); else if (request==REQ_Ox) out_html("OpenBSD "); else if (request==REQ_Bx) out_html("BSD "); else if (request==REQ_Ux) out_html("UNIX "); if (parsable) c=scan_troff_mandoc(c,1,0); else c=scan_troff(c,1,0); if (fillout) curpos++; else curpos=0; break; } case REQ_Dl: /* mdoc(7) */ { c=c+j; out_html(NEWLINE); out_html("<BLOCKQUOTE>"); if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</BLOCKQUOTE>"); if (fillout) curpos++; else curpos=0; break; } case REQ_Bd: /* mdoc(7) */ { /* Seems like a kind of example/literal mode */ char bd_options[NULL_TERMINATED(MED_STR_MAX)]; char *nl = strchr(c,'\n'); c=c+j; if (nl) strlimitcpy(bd_options, c, nl - c, MED_STR_MAX); out_html(NEWLINE); mandoc_bd_options = 0; /* Remember options for terminating Bl */ if (strstr(bd_options, "-offset indent")) { mandoc_bd_options |= BD_INDENT; out_html("<BLOCKQUOTE>\n"); } if ( strstr(bd_options, "-literal") || strstr(bd_options, "-unfilled")) { if (fillout) { mandoc_bd_options |= BD_LITERAL; out_html(set_font("R")); out_html(change_to_size('0')); out_html("<PRE>\n"); } curpos=0; fillout=0; } c=skip_till_newline(c); break; } case REQ_Ed: /* mdoc(7) */ { if (mandoc_bd_options & BD_LITERAL) { if (!fillout) { out_html(set_font("R")); out_html(change_to_size('0')); out_html("</PRE>\n"); } } if (mandoc_bd_options & BD_INDENT) out_html("</BLOCKQUOTE>\n"); curpos=0; fillout=1; c=skip_till_newline(c); break; } case REQ_Be: /* mdoc(7) */ { c=c+j; if (fillout) out_html("<br><br>"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Xr: /* mdoc(7) */ // ### FIXME: it should issue a <a href="man:somewhere(x)"> directly { /* Translate xyz 1 to xyz(1) * Allow for multiple spaces. Allow the section to be missing. */ char buff[NULL_TERMINATED(MED_STR_MAX)]; char *bufptr; trans_char(c,'"','\a'); bufptr = buff; c = c+j; if (*c == '\n') c++; /* Skip spaces */ while (isspace(*c) && *c != '\n') c++; while (isalnum(*c) || *c == '.' || *c == ':' || *c == '_' || *c == '-') { /* Copy the xyz part */ *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } while (isspace(*c) && *c != '\n') c++; /* Skip spaces */ if (isdigit(*c)) { /* Convert the number if there is one */ *bufptr = '('; bufptr++; if (bufptr < buff + MED_STR_MAX) { while (isalnum(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; c++; } if (bufptr < buff + MED_STR_MAX) { *bufptr = ')'; bufptr++; } } } while (*c != '\n') { /* Copy the remainder */ if (!isspace(*c)) { *bufptr = *c; bufptr++; if (bufptr >= buff + MED_STR_MAX) break; } c++; } *bufptr = '\n'; bufptr[1] = 0; scan_troff_mandoc(buff, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Fl: // mdoc(7) "FLags" { trans_char(c,'"','\a'); c+=j; sl=fill_words(c, wordlist, &words, true, &c); out_html(set_font("B")); if (!words) { out_html("-"); // stdin or stdout } else { for (i=0;i<words;++i) { if (ispunct(wordlist[i][0]) && wordlist[i][0]!='-') { scan_troff_mandoc(wordlist[i], 1, NULL); } else { if (i>0) out_html(" "); // Put a space between flags out_html("-"); scan_troff_mandoc(wordlist[i], 1, NULL); } } } out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pa: /* mdoc(7) */ case REQ_Pf: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Pp: /* mdoc(7) */ { if (fillout) out_html("<br><br>\n"); else { out_html(NEWLINE); } curpos=0; c=skip_till_newline(c); break; } case REQ_Aq: // mdoc(7) "Angle bracket Quote" c=process_quote(c,j,"&lt;","&gt;"); break; case REQ_Bq: // mdoc(7) "Bracket Quote" c=process_quote(c,j,"[","]"); break; case REQ_Dq: // mdoc(7) "Double Quote" c=process_quote(c,j,"&ldquo;","&rdquo;"); break; case REQ_Pq: // mdoc(7) "Parenthese Quote" c=process_quote(c,j,"(",")"); break; case REQ_Qq: // mdoc(7) "straight double Quote" c=process_quote(c,j,"&quot;","&quot;"); break; case REQ_Sq: // mdoc(7) "Single Quote" c=process_quote(c,j,"&lsquo;","&rsquo;"); break; case REQ_Op: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Oo: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("R")); out_html("["); c=scan_troff_mandoc(c, 1, NULL); if (fillout) curpos++; else curpos=0; break; } case REQ_Oc: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html("]"); if (fillout) curpos++; else curpos=0; break; } case REQ_Ql: /* mdoc(7) */ { /* Single quote first word in the line */ char *sp; trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; sp = c; do { /* Find first whitespace after the * first word that isn't a mandoc macro */ while (*sp && isspace(*sp)) sp++; while (*sp && !isspace(*sp)) sp++; } while (*sp && isupper(*(sp-2)) && islower(*(sp-1))); /* Use a newline to mark the end of text to * be quoted */ if (*sp) *sp = '\n'; out_html("`"); /* Quote the text */ c=scan_troff_mandoc(c, 1, NULL); out_html("'"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ar: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') { /* An empty Ar means "file ..." */ out_html("file ..."); } else c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Em: /* mdoc(7) */ { out_html("<em>"); trans_char(c,'"','\a'); c+=j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html("</em>"); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Ad: /* mdoc(7) */ case REQ_Va: /* mdoc(7) */ case REQ_Xc: /* mdoc(7) */ { /* parse one line in italics */ out_html(set_font("I")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nd: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(" - "); c=scan_troff_mandoc(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Nm: // mdoc(7) "Name Macro" ### FIXME { static char mandoc_name[NULL_TERMINATED(SMALL_STR_MAX)] = ""; // ### TODO Use QCString trans_char(c,'"','\a'); c=c+j; if (mandoc_synopsis && mandoc_name_count) { /* Break lines only in the Synopsis. * The Synopsis section seems to be treated * as a special case - Bummer! */ out_html("<BR>"); } else if (!mandoc_name_count) { const char *nextbreak = strchr(c, '\n'); const char *nextspace = strchr(c, ' '); if (nextspace < nextbreak) nextbreak = nextspace; if (nextbreak) { /* Remember the name for later. */ strlimitcpy(mandoc_name, c, nextbreak - c, SMALL_STR_MAX); } } mandoc_name_count++; out_html(set_font("B")); // ### FIXME: fill_words must be used while (*c == ' '|| *c == '\t') c++; if ((tolower(*c) >= 'a' && tolower(*c) <= 'z' ) || (*c >= '0' && *c <= '9')) { // alphanumeric argument c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); } else { /* If Nm has no argument, use one from an earlier * Nm command that did have one. Hope there aren't * too many commands that do this. */ out_html(mandoc_name); out_html(set_font("R")); } if (fillout) curpos++; else curpos=0; break; } case REQ_Cd: /* mdoc(7) */ case REQ_Cm: /* mdoc(7) */ case REQ_Ic: /* mdoc(7) */ case REQ_Ms: /* mdoc(7) */ case REQ_Or: /* mdoc(7) */ case REQ_Sy: /* mdoc(7) */ { /* parse one line in bold */ out_html(set_font("B")); trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_Dv: /* mdoc(7) */ case REQ_Ev: /* mdoc(7) */ case REQ_Fr: /* mdoc(7) */ case REQ_Li: /* mdoc(7) */ case REQ_No: /* mdoc(7) */ case REQ_Ns: /* mdoc(7) */ case REQ_Tn: /* mdoc(7) */ case REQ_nN: /* mdoc(7) */ { trans_char(c,'"','\a'); c=c+j; if (*c=='\n') c++; out_html(set_font("B")); c=scan_troff_mandoc(c, 1, NULL); out_html(set_font("R")); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; break; } case REQ_perc_A: /* mdoc(7) biblio stuff */ case REQ_perc_D: case REQ_perc_N: case REQ_perc_O: case REQ_perc_P: case REQ_perc_Q: case REQ_perc_V: { c=c+j; if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ if (fillout) curpos++; else curpos=0; break; } case REQ_perc_B: case REQ_perc_J: case REQ_perc_R: case REQ_perc_T: { c=c+j; out_html(set_font("I")); if (*c=='\n') c++; c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */ out_html(set_font("R")); if (fillout) curpos++; else curpos=0; break; } case REQ_UR: // ### FIXME man(7) "URl" { ignore_links=true; c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; // A parameter : means that we do not want an URL, not here and not until .UE ur_ignore=(!qstrcmp(h,":")); } else { // We cannot find the URL, assume : ur_ignore=true; h=0; } if (!ur_ignore && words>0) { out_html("<a href=\""); out_html(h); out_html("\">"); } c=newc; // Go to next line break; } case REQ_UE: // ### FIXME man(7) "Url End" { c+=j; c = skip_till_newline(c); if (!ur_ignore) { out_html("</a>"); } ur_ignore=false; ignore_links=false; break; } case REQ_UN: // ### FIXME man(7) "Url Named anchor" { c+=j; char* newc; h=fill_words(c, wordlist, &words, false, &newc); *h=0; if (words>0) { h=wordlist[0]; out_html("<a name=\">"); out_html(h); out_html("\" id=\""); out_html(h); out_html("\"></a>"); } c=newc; break; } case REQ_nroff: // groff(7) "NROFF mode" mode = true; case REQ_troff: // groff(7) "TROFF mode" { s_nroff = mode; c+=j; c = skip_till_newline(c); } case REQ_als: // groff(7) "ALias String" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rn, the destination is first, origin is second kdDebug(7107) << "start .als" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination string to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c=skip_till_newline(c); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination string to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rn) QMap<QCString,StringDefinition>::iterator it=s_stringDefinitionMap.find(name2); if (it==s_stringDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { StringDefinition def=(*it); s_stringDefinitionMap.insert(name,def); } kdDebug(7107) << "end .als" << endl; break; } case REQ_rr: // groff(7) "Remove number Register" { kdDebug(7107) << "start .rr" << endl; c += j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin string to remove/rename: " << endl; break; } c = skip_till_newline( c ); QMap <QCString, NumberDefinition>::iterator it = s_numberDefinitionMap.find( name ); if ( it == s_numberDefinitionMap.end() ) { kdDebug(7107) << "EXCEPTION: trying to remove inexistant number register: " << endl; } else { s_numberDefinitionMap.remove( name ); } kdDebug(7107) << "end .rr" << endl; break; } case REQ_rnn: // groff(7) "ReName Number register" { kdDebug(7107) << "start .rnn" << endl; c+=j; const QCString name ( scan_identifier ( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin to remove/rename number register" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier ( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination to rename number register " << endl; break; } c = skip_till_newline( c ); QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find number register to rename: " << name << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.remove(name); // ### QT4: removeAll s_numberDefinitionMap.insert(name2,def); } kdDebug(7107) << "end .rnn" << endl; break; } case REQ_aln: // groff(7) "ALias Number Register" { /* * Note an alias is supposed to be something like a hard link * However to make it simplier, we only copy the string. */ // Be careful: unlike .rnn, the destination is first, origin is second kdDebug(7107) << "start .aln" << endl; c+=j; const QCString name ( scan_identifier( c ) ); if ( name.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty destination number register to alias" << endl; break; } while (*c && isspace(*c) && *c!='\n') ++c; const QCString name2 ( scan_identifier( c ) ); if ( name2.isEmpty() ) { kdDebug(7107) << "EXCEPTION: empty origin number register to alias" << endl; break; } kdDebug(7107) << "Alias " << name2 << " to " << name << endl; c = skip_till_newline( c ); if ( name == name2 ) { kdDebug(7107) << "EXCEPTION: same origin and destination number register to alias: " << name << endl; break; } // Second parametr is origin (unlike in .rnn) QMap<QCString,NumberDefinition>::iterator it=s_numberDefinitionMap.find(name2); if (it==s_numberDefinitionMap.end()) { kdDebug(7107) << "EXCEPTION: cannot find string to make alias: " << name2 << endl; } else { NumberDefinition def=(*it); s_numberDefinitionMap.insert(name,def); } kdDebug(7107) << "end .aln" << endl; break; } case REQ_shift: // groff(7) "SHIFT parameter" { c+=j; h=c; while (*h && *h!='\n' && isdigit(*h) ) ++h; const char tempchar = *h; *h = 0; const QCString number = c; *h = tempchar; c = skip_till_newline( h ); unsigned int result = 1; // Numbers of shifts to do if ( !number.isEmpty() ) { bool ok = false; result = number.toUInt(&ok); if ( !ok || result < 1 ) result = 1; } for ( unsigned int num = 0; num < result; ++num ) { if ( !s_argumentList.isEmpty() ) s_argumentList.pop_front(); } break; } case REQ_while: // groff(7) "WHILE loop" { request_while( c, j, mandoc_command ); break; } default: { if (mandoc_command && ((isupper(*c) && islower(*(c+1))) || (islower(*c) && isupper(*(c+1)))) ) { /* Let through any mdoc(7) commands that haven't * been delt with. * I don't want to miss anything out of the text. */ char buf[4]; qstrncpy(buf,c,2); buf[2] = ' '; buf[3] = '\0'; out_html(buf); /* Print the command (it might just be text). */ c=c+j; trans_char(c,'"','\a'); if (*c=='\n') c++; out_html(set_font("R")); c=scan_troff(c, 1, NULL); out_html(NEWLINE); if (fillout) curpos++; else curpos=0; } else c=skip_till_newline(c); break; } } } } if (fillout) { out_html(NEWLINE); curpos++; } return c;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a2a0d621d2afd22ae7cf2ad733a2ce62a96b2010/man2html.cpp/buggy/kioslave/man/man2html.cpp