From bd1b0cb4eea34d7918c98aa42423078af0dd329a Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Wed, 6 Jan 2021 05:56:38 -0800 Subject: [PATCH 001/244] Removed Ruby Files since they were not maintained. --- languages/cprogs/mined1.c | 1987 -------------------- languages/ruby/being_rescue_else_ensure.rb | 11 - languages/ruby/check_nil.rb | 6 - languages/ruby/class_and_object.rb | 22 - languages/ruby/conditionals.rb | 4 - languages/ruby/constant_assignment.rb | 2 - languages/ruby/forloop.rb | 4 - languages/ruby/handle_exceptions.rb | 16 - languages/ruby/if_statement.rb | 5 - languages/ruby/include_modules.rb | 2 - languages/ruby/introspect.rb | 20 - languages/ruby/iterate_each.rb | 4 - languages/ruby/kernel_method.rb | 5 - languages/ruby/module_mixin.rb | 18 - languages/ruby/modules_with_methods.rb | 45 - languages/ruby/open_url.rb | 5 - languages/ruby/puts_examples.rb | 7 - languages/ruby/puts_functionname.rb | 6 - languages/ruby/require_stmt.rb | 2 - languages/ruby/ruby13.rb | 2 - languages/ruby/ruby16.rb | 2 - languages/ruby/ruby5.rb | 7 - languages/ruby/ruby7.rb | 6 - languages/ruby/ruby_function.rb | 7 - languages/ruby/see_backtrace.rb | 13 - languages/ruby/simpleNumber.rb | 14 - languages/ruby/string_methods.rb | 4 - languages/ruby/string_templates.rb | 3 - languages/ruby/string_times.rb | 1 - languages/ruby/tc_simpleNumber.rb | 9 - source/index.rst | 8 - source/ruby/being_rescue_else_ensure.rst | 34 - source/ruby/check_nil.rst | 34 - source/ruby/class_and_object.rst | 34 - source/ruby/conditionals.rst | 34 - source/ruby/constant_assignment.rst | 34 - source/ruby/forloop.rst | 32 - source/ruby/handle_exceptions.rst | 34 - source/ruby/if_statement.rst | 35 - source/ruby/include_modules.rst | 35 - source/ruby/index.rst | 43 - source/ruby/introspect.rst | 35 - source/ruby/iterate_each.rst | 35 - source/ruby/kernel_method.rst | 35 - source/ruby/module_mixin.rst | 33 - source/ruby/modules_with_methods.rst | 35 - source/ruby/open_url.rst | 35 - source/ruby/puts_examples.rst | 35 - source/ruby/puts_functionname.rst | 35 - source/ruby/require_stmt.rst | 35 - source/ruby/ruby13.rst | 35 - source/ruby/ruby16.rst | 35 - source/ruby/ruby5.rst | 35 - source/ruby/ruby7.rst | 35 - source/ruby/ruby_function.rst | 35 - source/ruby/see_backtrace.rst | 35 - source/ruby/simpleNumber.rst | 35 - source/ruby/string_methods.rst | 35 - source/ruby/string_templates.rst | 35 - source/ruby/string_times.rst | 35 - source/ruby/tc_simpleNumber.rst | 35 - 61 files changed, 3294 deletions(-) delete mode 100644 languages/cprogs/mined1.c delete mode 100644 languages/ruby/being_rescue_else_ensure.rb delete mode 100644 languages/ruby/check_nil.rb delete mode 100644 languages/ruby/class_and_object.rb delete mode 100644 languages/ruby/conditionals.rb delete mode 100644 languages/ruby/constant_assignment.rb delete mode 100644 languages/ruby/forloop.rb delete mode 100644 languages/ruby/handle_exceptions.rb delete mode 100644 languages/ruby/if_statement.rb delete mode 100644 languages/ruby/include_modules.rb delete mode 100644 languages/ruby/introspect.rb delete mode 100644 languages/ruby/iterate_each.rb delete mode 100644 languages/ruby/kernel_method.rb delete mode 100644 languages/ruby/module_mixin.rb delete mode 100644 languages/ruby/modules_with_methods.rb delete mode 100644 languages/ruby/open_url.rb delete mode 100644 languages/ruby/puts_examples.rb delete mode 100644 languages/ruby/puts_functionname.rb delete mode 100644 languages/ruby/require_stmt.rb delete mode 100644 languages/ruby/ruby13.rb delete mode 100644 languages/ruby/ruby16.rb delete mode 100644 languages/ruby/ruby5.rb delete mode 100644 languages/ruby/ruby7.rb delete mode 100644 languages/ruby/ruby_function.rb delete mode 100644 languages/ruby/see_backtrace.rb delete mode 100644 languages/ruby/simpleNumber.rb delete mode 100644 languages/ruby/string_methods.rb delete mode 100644 languages/ruby/string_templates.rb delete mode 100644 languages/ruby/string_times.rb delete mode 100644 languages/ruby/tc_simpleNumber.rb delete mode 100644 source/ruby/being_rescue_else_ensure.rst delete mode 100644 source/ruby/check_nil.rst delete mode 100644 source/ruby/class_and_object.rst delete mode 100644 source/ruby/conditionals.rst delete mode 100644 source/ruby/constant_assignment.rst delete mode 100644 source/ruby/forloop.rst delete mode 100644 source/ruby/handle_exceptions.rst delete mode 100644 source/ruby/if_statement.rst delete mode 100644 source/ruby/include_modules.rst delete mode 100644 source/ruby/index.rst delete mode 100644 source/ruby/introspect.rst delete mode 100644 source/ruby/iterate_each.rst delete mode 100644 source/ruby/kernel_method.rst delete mode 100644 source/ruby/module_mixin.rst delete mode 100644 source/ruby/modules_with_methods.rst delete mode 100644 source/ruby/open_url.rst delete mode 100644 source/ruby/puts_examples.rst delete mode 100644 source/ruby/puts_functionname.rst delete mode 100644 source/ruby/require_stmt.rst delete mode 100644 source/ruby/ruby13.rst delete mode 100644 source/ruby/ruby16.rst delete mode 100644 source/ruby/ruby5.rst delete mode 100644 source/ruby/ruby7.rst delete mode 100644 source/ruby/ruby_function.rst delete mode 100644 source/ruby/see_backtrace.rst delete mode 100644 source/ruby/simpleNumber.rst delete mode 100644 source/ruby/string_methods.rst delete mode 100644 source/ruby/string_templates.rst delete mode 100644 source/ruby/string_times.rst delete mode 100644 source/ruby/tc_simpleNumber.rst diff --git a/languages/cprogs/mined1.c b/languages/cprogs/mined1.c deleted file mode 100644 index 7c1f88fb..00000000 --- a/languages/cprogs/mined1.c +++ /dev/null @@ -1,1987 +0,0 @@ -/* - * Part one of the mined editor. - */ - -/* - * Author: Michiel Huisjes. - * - * 1. General remarks. - * - * Mined is a screen editor designed for the MINIX operating system. - * It is meant to be used on files not larger than 50K and to be fast. - * When mined starts up, it reads the file into its memory to minimize - * disk access. The only time that disk access is needed is when certain - * save, write or copy commands are given. - * - * Mined has the style of Emacs or Jove, that means that there are no modes. - * Each character has its own entry in an 256 pointer to function array, - * which is called when that character is typed. Only ASCII characters are - * connected with a function that inserts that character at the current - * location in the file. Two execptions are and which are - * inserted as well. Note that the mapping between commands and functions - * called is implicit in the table. Changing the mapping just implies - * changing the pointers in this table. - * - * The display consists of SCREENMAX + 1 lines and XMAX + 1 characters. When - * a line is larger (or gets larger during editing) than XBREAK characters, - * the line is either shifted SHIFT_SIZE characters to the left (which means - * that the first SHIFT_SIZE characters are not printed) or the end of the - * line is marked with the SHIFT_MARK character and the rest of the line is - * not printed. A line can never exceed MAX_CHARS characters. Mined will - * always try to keep the cursor on the same line and same (relative) - * x-coordinate if nothing changed. So if you scroll one line up, the cursor - * stays on the same line, or when you move one line down, the cursor will - * move to the same place on the line as it was on the previous. - * Every character on the line is available for editing including the - * linefeed at the the of the line. When the linefeed is deleted, the current - * line and the next line are joined. The last character of the file (which - * is always a linefeed) can never be deleted. - * The bottomline (as indicated by YMAX + 1) is used as a status line during - * editing. This line is usually blank or contains information mined needs - * during editing. This information (or rather questions) is displayed in - * reverse video. - * - * The terminal modes are changed completely. All signals like start/stop, - * interrupt etc. are unset. The only signal that remains is the quit signal. - * The quit signal (^\) is the general abort signal for mined. Typing a ^\ - * during searching or when mined is asking for filenames, etc. will abort - * the function and mined will return to the main loop. Sending a quit - * signal during the main loop will abort the session (after confirmation) - * and the file is not (!) saved. - * The session will also be aborted when an unrecoverable error occurs. E.g - * when there is no more memory available. If the file has been modified, - * mined will ask if the file has to be saved or not. - * If there is no more space left on the disk, mined will just give an error - * message and continue. - * - * The number of system calls are minized. This is done to keep the editor - * as fast as possible. I/O is done in SCREEN_SIZE reads/writes. Accumulated - * output is also flushed at the end of each character typed. - * - * 2. Regular expressions - * - * Mined has a build in regular expression matcher, which is used for - * searching and replace routines. A regular expression consists of a - * sequence of: - * - * 1. A normal character matching that character. - * 2. A . matching any character. - * 3. A ^ matching the begin of a line. - * 4. A $ (as last character of the pattern) mathing the end of a line. - * 5. A \ matching . - * 6. A number of characters enclosed in [] pairs matching any of these - * characters. A list of characters can be indicated by a '-'. So - * [a-z] matches any letter of the alphabet. If the first character - * after the '[' is a '^' then the set is negated (matching none of - * the characters). - * A ']', '^' or '-' can be escaped by putting a '\' in front of it. - * Of course this means that a \ must be represented by \\. - * 7. If one of the expressions as described in 1-6 is followed by a - * '*' than that expressions matches a sequence of 0 or more of - * that expression. - * - * Parsing of regular expression is done in two phases. In the first phase - * the expression is compiled into a more comprehensible form. In the second - * phase the actual matching is done. For more details see 3.6. - * - * - * 3. Implementation of mined. - * - * 3.1 Data structures. - * - * The main data structures are as follows. The whole file is kept in a - * double linked list of lines. The LINE structure looks like this: - * - * typedef struct Line { - * struct Line *next; - * struct Line *prev; - * char *text; - * unsigned char shift_count; - * } LINE; - * - * Each line entry contains a pointer to the next line, a pointer to the - * previous line and a pointer to the text of that line. A special field - * shift_count contains the number of shifts (in units of SHIFT_SIZE) - * that is performed on that line. The total size of the structure is 7 - * bytes so a file consisting of 1000 empty lines will waste a lot of - * memory. A LINE structure is allocated for each line in the file. After - * that the number of characters of the line is counted and sufficient - * space is allocated to store them (including a linefeed and a '\0'). - * The resulting address is assigned to the text field in the structure. - * - * A special structure is allocated and its address is assigned to the - * variable header as well as the variable tail. The text field of this - * structure is set to NIL_PTR. The tail->prev of this structure points - * to the last LINE of the file and the header->next to the first LINE. - * Other LINE *variables are top_line and bot_line which point to the - * first line resp. the last line on the screen. - * Two other variables are important as well. First the LINE *cur_line, - * which points to the LINE currently in use and the char *cur_text, - * which points to the character at which the cursor stands. - * Whenever an ASCII character is typed, a new line is build with this - * character inserted. Then the old data space (pointed to by - * cur_line->text) is freed, data space for the new line is allocated and - * assigned to cur_line->text. - * - * Two global variables called x and y represent the x and y coordinates - * from the cursor. The global variable nlines contains the number of - * lines in the file. Last_y indicates the maximum y coordinate of the - * screen (which is usually SCREENMAX). - * - * A few strings must be initialized by hand before compiling mined. - * These string are enter_string, which is printed upon entering mined, - * rev_video (turn on reverse video), normal_video, rev_scroll (perform a - * reverse scroll) and pos_string. The last string should hold the - * absolute position string to be printed for cursor motion. The #define - * X_PLUS and Y_PLUS should contain the characters to be added to the - * coordinates x and y (both starting at 0) to finish cursor positioning. - * - * 3.2 Starting up. - * - * Mined can be called with or without argument and the function - * load_file () is called with these arguments. load_file () checks - * if the file exists if it can be read and if it is writable and - * sets the writable flag accordingly. If the file can be read, - * load_file () reads a line from the file and stores this line into - * a structure by calling install_line () and line_insert () which - * installs the line into the double linked list, until the end of the - * file is reached. - * Lines are read by the function get_line (), which buffers the - * reading in blocks of SCREEN_SIZE. Load_file () also initializes the - * LINE *variables described above. - * - * 3.3 Moving around. - * - * Several commands are implemented for moving through the file. - * Moving up (UP), down (DN) left (LF) and right (RT) are done by the - * arrow keys. Moving one line below the screen scrolls the screen one - * line up. Moving one line above the screen scrolls the screen one line - * down. The functions forward_scroll () and reverse_scroll () take care - * of that. - * Several other move functions exist: move to begin of line (BL), end of - * line (EL) top of screen (HIGH), bottom of screen (LOW), top of file - * (HO), end of file (EF), scroll one page down (PD), scroll one page up - * (PU), scroll one line down (SD), scroll one line up (SU) and move to a - * certain line number (GOTO). - * Two functions called MN () and MP () each move one word further or - * backwards. A word is a number of non-blanks seperated by a space, a - * tab or a linefeed. - * - * 3.4 Modifying text. - * - * The modifying commands can be separated into two modes. The first - * being inserting text, and the other deleting text. Two functions are - * created for these purposes: insert () and delete (). Both are capable - * of deleting or inserting large amounts of text as well as one - * character. Insert () must be given the line and location at which - * the text must be inserted. Is doesn't make any difference whether this - * text contains linefeeds or not. Delete () must be given a pointer to - * the start line, a pointer from where deleting should start on that - * line and the same information about the end position. The last - * character of the file will never be deleted. Delete () will make the - * necessary changes to the screen after deleting, but insert () won't. - * The functions for modifying text are: insert one char (S), insert a - * file (file_insert (fd)), insert a linefeed and put cursor back to - * end of line (LIB), delete character under the cursor (DCC), delete - * before cursor (even linefeed) (DPC), delete next word (DNW), delete - * previous word (DPC) and delete to end of line (if the cursor is at - * a linefeed delete line) (DLN). - * - * 3.5 Yanking. - * - * A few utilities are provided for yanking pieces of text. The function - * MA () marks the current position in the file. This is done by setting - * LINE *mark_line and char *mark_text to the current position. Yanking - * of text can be done in two modes. The first mode just copies the text - * from the mark to the current position (or visa versa) into a buffer - * (YA) and the second also deletes the text (DT). Both functions call - * the function set_up () with the delete flag on or off. Set_up () - * checks if the marked position is still a valid one (by using - * check_mark () and legal ()), and then calls the function yank () with - * a start and end position in the file. This function copies the text - * into a scratch_file as indicated by the variable yank_file. This - * scratch_file is made uniq by the function scratch_file (). At the end - * of copying yank will (if necessary) delete the text. A global flag - * called yank_status keeps track of the buffer (or file) status. It is - * initialized on NOT_VALID and set to EMPTY (by set_up ()) or VALID (by - * yank ()). Several things can be done with the buffer. It can be - * inserted somewhere else in the file (PT) or it can be copied into - * another file (WB), which will be prompted for. - * - * 3.6 Search and replace routines. - * - * Searching for strings and replacing strings are done by regular - * expressions. For any expression the function compile () is called - * with as argument the expression to compile. Compile () returns a - * pointer to a structure which looks like this: - * - * typedef struct regex { - * union { - * char *err_mess; - * int *expression; - * } result; - * char status; - * char *start_ptr; - * char *end_ptr; - * } REGEX; - * - * If something went wrong during compiling (e.g. an illegal expression - * was given), the function reg_error () is called, which sets the status - * field to REG_ERROR and the err_mess field to the error message. If the - * match must be anchored at the beginning of the line (end of line), the - * status field is set to BEGIN_LINE (END_LINE). If none of these special - * cases are true, the field is set to 0 and the function finished () is - * called. Finished () allocates space to hold the compiled expression - * and copies this expression into the expression field of the union - * (bcopy ()). Matching is done by the routines match() and line_check(). - * Match () takes as argument the REGEX *program, a pointer to the - * startposition on the current line, and a flag indicating FORWARD or - * REVERSE search. Match () checks out the whole file until a match is - * found. If match is found it returns a pointer to the line in which the - * match was found else it returns a NIL_LINE. Line_check () takes the - * same arguments, but return either MATCH or NO_MATCH. - * During checking, the start_ptr and end_ptr fields of the REGEX - * structure are assigned to the start and end of the match. - * Both functions try to find a match by walking through the line - * character by character. For each possibility, the function - * check_string () is called with as arguments the REGEX *program and the - * string to search in. It starts walking through the expression until - * the end of the expression or the end of the string is reached. - * Whenever a * is encountered, this position of the string is marked, - * the maximum number of matches are performed and the function star () - * is called in order to try to find the longest match possible. Star () - * takes as arguments the REGEX program, the current position of the - * string, the marked position and the current position of the expression - * Star () walks from the current position of the string back to the - * marked position, and calls string_check () in order to find a match. - * It returns MATCH or NO_MATCH, just as string_check () does. - * Searching is now easy. Both search routines (forward (SF) and - * backwards search (SR)) call search () with an apropiate message and a - * flag indicating FORWARD or REVERSE search. Search () will get an - * expression from the user by calling get_expression(). Get_expression() - * returns a pointer to a REGEX structure or NIL_REG upon errors and - * prompts for the expression. If no expression if given, the previous is - * used instead. After that search will call match (), and if a match is - * found, we can move to that place in the file by the functions find_x() - * and find_y () which will find display the match on the screen. - * Replacing can be done in two ways. A global replace (GR) or a line - * replace (LR). Both functions call change () with a message an a flag - * indicating global or line replacement. Change () will prompt for the - * expression and for the replacement. Every & in the replacement pattern - * means substitute the match instead. An & can be escaped by a \. When - * a match is found, the function substitute () will perform the - * substitution. - * - * 3.6 Miscellaneous commands. - * - * A few commands haven't be discussed yet. These are redraw the screen - * (RD) fork a shell (SH), print file status (FS), write file to disc - * (WT), insert a file at current position (IF), leave editor (XT) and - * visit another file (VI). The last two functions will check if the file - * has been modified. If it has, they will ask if you want to save the - * file by calling ask_save (). - * The function ESC () will repeat a command n times. It will prompt for - * the number. Aborting the loop can be done by sending the ^\ signal. - * - * 3.7 Utility functions. - * - * Several functions exists for internal use. First allocation routines: - * alloc (bytes) and newline () will return a pointer to free data space - * if the given size. If there is no more memory available, the function - * panic () is called. - * Signal handling: The only signal that can be send to mined is the - * SIGQUIT signal. This signal, functions as a general abort command. - * Mined will abort if the signal is given during the main loop. The - * function abort_mined () takes care of that. - * Panic () is a function with as argument a error message. It will print - * the message and the error number set by the kernel (errno) and will - * ask if the file must be saved or not. It resets the terminal - * (raw_mode ()) and exits. - * String handling routines like copy_string(to, from), length_of(string) - * and build_string (buffer, format, arg1, arg2, ...). The latter takes - * a description of the string out out the format field and puts the - * result in the buffer. (It works like printf (3), but then into a - * string). The functions status_line (string1, string2), error (string1, - * string2), clear_status () and bottom_line () all print information on - * the status line. - * Get_string (message, buffer) reads a string and getchar () reads one - * character from the terminal. - * Num_out ((long) number) prints the number into a 11 digit field - * without leading zero's. It returns a pointer to the resulting string. - * File_status () prints all file information on the status line. - * Set_cursor (x, y) prints the string to put the cursor at coordinates - * x and y. - * Output is done by four functions: writeline(fd,string), clear_buffer() - * write_char (fd, c) and flush_buffer (fd). Three defines are provided - * to write on filedescriptor STD_OUT (terminal) which is used normally: - * string_print (string), putchar (c) and flush (). All these functions - * use the global I/O buffer screen and the global index for this array - * called out_count. In this way I/O can be buffered, so that reads or - * writes can be done in blocks of SCREEN_SIZE size. - * The following functions all handle internal line maintenance. The - * function proceed (start_line, count) returns the count'th line after - * start_line. If count is negative, the count'th line before the - * start_line is returned. If header or tail is encountered then that - * will be returned. Display (x, y, start_line, count) displays count - * lines starting at coordinates [x, y] and beginning at start_line. If - * the header or tail is encountered, empty lines are displayed instead. - * The function reset (head_line, ny) reset top_line, last_y, bot_line, - * cur_line and y-coordinate. This is not a neat way to do the - * maintenance, but it sure saves a lot of code. It is usually used in - * combination with display (). - * Put_line(line, offset, clear_line), prints a line (skipping characters - * according to the line->shift_size field) until XBREAK - offset - * characters are printed or a '\n' is encountered. If clear_line is - * TRUE, spaces are printed until XBREAK - offset characters. - * Line_print (line) is a #define from put_line (line, 0, TRUE). - * Moving is done by the functions move_to (x, y), move_addres (address) - * and move (x, adress, y). This function is the most important one in - * mined. New_y must be between 0 and last_y, new_x can be about - * anything, address must be a pointer to an character on the current - * line (or y). Move_to () first adjust the y coordinate together with - * cur_line. If an address is given, it finds the corresponding - * x-coordinate. If an new x-coordinate was given, it will try to locate - * the corresponding character. After that it sets the shift_count field - * of cur_line to an apropiate number according to new_x. The only thing - * left to do now is to assign the new values to cur_line, cur_text, x - * and y. - * - * 4. Summary of commands. - * - * CURSOR MOTION - * up-arrow Move cursor 1 line up. At top of screen, reverse scroll - * down-arrow Move cursor 1 line down. At bottom, scroll forward. - * left-arrow Move cursor 1 character left or to end of previous line - * right-arrow Move cursor 1 character right or to start of next line - * CTRL-A Move cursor to start of current line - * CTRL-Z Move cursor to end of current line - * CTRL-^ Move cursor to top of screen - * CTRL-_ Move cursor to bottom of screen - * CTRL-F Forward to start of next word (even to next line) - * CTRL-B Backward to first character of previous word - * - * SCREEN MOTION - * Home key Move cursor to first character of file - * End key Move cursor to last character of file - * PgUp Scroll backward 1 page. Bottom line becomes top line - * PgD Scroll backward 1 page. Top line becomes bottom line - * CTRL-D Scroll screen down one line (reverse scroll) - * CTRL-U Scroll screen up one line (forward scroll) - * - * MODIFYING TEXT - * ASCII char Self insert character at cursor - * tab Insert tab at cursor - * backspace Delete the previous char (left of cursor), even line feed - * Del Delete the character under the cursor - * CTRL-N Delete next word - * CTRL-P Delete previous word - * CTRL-O Insert line feed at cursor and back up 1 character - * CTRL-T Delete tail of line (cursor to end); if empty, delete line - * CTRL-@ Set the mark (remember the current location) - * CTRL-K Delete text from the mark to current position save on file - * CTRL-C Save the text from the mark to the current position - * CTRL-Y Insert the contents of the save file at current position - * CTRL-Q Insert the contents of the save file into a new file - * CTRL-G Insert a file at the current position - * - * MISCELLANEOUS - * CTRL-E Erase and redraw the screen - * CTRL-V Visit file (read a new file); complain if old one changed - * CTRL-W Write the current file back to the disk - * numeric + Search forward (prompt for regular expression) - * numeric - Search backward (prompt for regular expression) - * numeric 5 Print the current status of the file - * CTRL-R (Global) Replace str1 by str2 (prompts for each string) - * CTRL-L (Line) Replace string1 by string2 - * CTRL-S Fork off a shell and wait for it to finish - * CTRL-X EXIT (prompt if file modified) - * CTRL-] Go to a line. Prompts for linenumber - * CTRL-\ Abort whatever editor was doing and start again - * escape key Repeat a command count times; (prompts for count) - */ - -/* ======================================================================== * - * Utilities * - * ======================================================================== */ - -#include "mined.h" -#include -#include -#include -#include -#include -#include -#if __STDC__ -#include -#else -#include -#endif - -extern int errno; -int ymax = YMAX; -int screenmax = SCREENMAX; - - -/* - * Print file status. - */ -void FS() -{ - fstatus(file_name[0] ? "" : "[buffer]", -1L); -} - -/* - * Visit (edit) another file. If the file has been modified, ask the user if - * he wants to save it. - */ -void VI() -{ - char new_file[LINE_LEN]; /* Buffer to hold new file name */ - - if (modified == TRUE && ask_save() == ERRORS) - return; - -/* Get new file name */ - if (get_file("Visit file:", new_file) == ERRORS) - return; - -/* Free old linked list, initialize global variables and load new file */ - initialize(); -#ifdef UNIX - tputs(CL, 0, _putchar); -#else - string_print (enter_string); -#endif /* UNIX */ - load_file(new_file[0] == '\0' ? NIL_PTR : new_file); -} - -/* - * Write file in core to disc. - */ -int WT() -{ - register LINE *line; - register long count = 0L; /* Nr of chars written */ - char file[LINE_LEN]; /* Buffer for new file name */ - int fd; /* Filedescriptor of file */ - - if (modified == FALSE) { - error ("Write not necessary.", NIL_PTR); - return FINE; - } - -/* Check if file_name is valid and if file can be written */ - if (file_name[0] == '\0' || writable == FALSE) { - if (get_file("Enter file name:", file) != FINE) - return ERRORS; - copy_string(file_name, file); /* Save file name */ - } - if ((fd = creat(file_name, 0644)) < 0) { /* Empty file */ - error("Cannot create ", file_name); - writable = FALSE; - return ERRORS; - } - else - writable = TRUE; - - clear_buffer(); - - status_line("Writing ", file_name); - for (line = header->next; line != tail; line = line->next) { - if (line->shift_count & DUMMY) { - if (line->next == tail && line->text[0] == '\n') - continue; - } - if (writeline(fd, line->text) == ERRORS) { - count = -1L; - break; - } - count += (long) length_of(line->text); - } - - if (count > 0L && flush_buffer(fd) == ERRORS) - count = -1L; - - (void) close(fd); - - if (count == -1L) - return ERRORS; - - modified = FALSE; - rpipe = FALSE; /* File name is now assigned */ - -/* Display how many chars (and lines) were written */ - fstatus("Wrote", count); - return FINE; -} - -/* Call WT and discard value returned. */ -void XWT() -{ - (void) WT(); -} - - - -/* - * Call an interactive shell. - */ -void SH() -{ - register int w; - int pid, status; - char *shell; - - if ((shell = getenv("SHELL")) == NIL_PTR) shell = "/bin/sh"; - - switch (pid = fork()) { - case -1: /* Error */ - error("Cannot fork.", NIL_PTR); - return; - case 0: /* This is the child */ - set_cursor(0, ymax); - putchar('\n'); - flush(); - raw_mode(OFF); - if (rpipe) { /* Fix stdin */ - close (0); - if (open("/dev/tty", 0) < 0) - exit (126); - } - execl(shell, shell, (char *) 0); - exit(127); /* Exit with 127 */ - default : /* This is the parent */ - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - do { - w = wait(&status); - } while (w != -1 && w != pid); - } - - raw_mode(ON); - RD(); - - if ((status >> 8) == 127) /* Child died with 127 */ - error("Cannot exec ", shell); - else if ((status >> 8) == 126) - error("Cannot open /dev/tty as fd #0", NIL_PTR); -} - -/* - * Proceed returns the count'th line after `line'. When count is negative - * it returns the count'th line before `line'. When the next (previous) - * line is the tail (header) indicating EOF (tof) it stops. - */ -LINE *proceed(line, count) -register LINE *line; -register int count; -{ - if (count < 0) - while (count++ < 0 && line != header) - line = line->prev; - else - while (count-- > 0 && line != tail) - line = line->next; - return line; -} - -/* - * Show concatenation of s1 and s2 on the status line (bottom of screen) - * If revfl is TRUE, turn on reverse video on both strings. Set stat_visible - * only if bottom_line is visible. - */ -int bottom_line(revfl, s1, s2, inbuf, statfl) -FLAG revfl; -char *s1, *s2; -char *inbuf; -FLAG statfl; -{ - int ret = FINE; - char buf[LINE_LEN]; - register char *p = buf; - - *p++ = ' '; - if (s1 != NIL_PTR) - while (*p = *s1++) - p++; - if (s2 != NIL_PTR) - while (*p = *s2++) - p++; - *p++ = ' '; - *p++ = 0; - - if (revfl == ON && stat_visible == TRUE) - clear_status (); - set_cursor(0, ymax); - if (revfl == ON) { /* Print rev. start sequence */ -#ifdef UNIX - tputs(SO, 0, _putchar); -#else - string_print(rev_video); -#endif /* UNIX */ - stat_visible = TRUE; - } - else /* Used as clear_status() */ - stat_visible = FALSE; - - string_print(buf); - - if (inbuf != NIL_PTR) - ret = input(inbuf, statfl); - - /* Print normal video */ -#ifdef UNIX - tputs(SE, 0, _putchar); - tputs(CE, 0, _putchar); -#else - string_print(normal_video); - string_print(blank_line); /* Clear the rest of the line */ -#endif /* UNIX */ - if (inbuf != NIL_PTR) - set_cursor(0, ymax); - else - set_cursor(x, y); /* Set cursor back to old position */ - flush(); /* Perform the actual write */ - if (ret != FINE) - clear_status(); - return ret; -} - -/* - * Count_chars() count the number of chars that the line would occupy on the - * screen. Counting starts at the real x-coordinate of the line. - */ -int count_chars(line) -LINE *line; -{ - register int cnt = get_shift(line->shift_count) * -SHIFT_SIZE; - register char *textp = line->text; - -/* Find begin of line on screen */ - while (cnt < 0) { - if (is_tab(*textp++)) - cnt = tab(cnt); - else - cnt++; - } - -/* Count number of chars left */ - cnt = 0; - while (*textp != '\n') { - if (is_tab(*textp++)) - cnt = tab(cnt); - else - cnt++; - } - return cnt; -} - -/* - * Move to coordinates nx, ny at screen. The caller must check that scrolling - * is not needed. - * If new_x is lower than 0 or higher than XBREAK, move_to() will check if - * the line can be shifted. If it can it sets(or resets) the shift_count field - * of the current line accordingly. - * Move also sets cur_text to the right char. - * If we're moving to the same x coordinate, try to move the the x-coordinate - * used on the other previous call. - */ -void move(new_x, new_address, new_y) -register int new_x; -int new_y; -char *new_address; -{ - register LINE *line = cur_line; /* For building new cur_line */ - int shift = 0; /* How many shifts to make */ - static int rel_x = 0; /* Remember relative x position */ - int tx = x; - -/* Check for illegal values */ - if (new_y < 0 || new_y > last_y) - return; - -/* Adjust y-coordinate and cur_line */ - if (new_y < y) - while (y != new_y) { - y--; - line = line->prev; - } - else - while (y != new_y) { - y++; - line = line->next; - } - -/* Set or unset relative x-coordinate */ - if (new_address == NIL_PTR) { - new_address = find_address(line, (new_x == x) ? rel_x : new_x , &tx); - if (new_x != x) - rel_x = tx; - new_x = tx; - } - else - rel_x = new_x = find_x(line, new_address); - -/* Adjust shift_count if new_x lower than 0 or higher than XBREAK */ - if (new_x < 0 || new_x >= XBREAK) { - if (new_x > XBREAK || (new_x == XBREAK && *new_address != '\n')) - shift = (new_x - XBREAK) / SHIFT_SIZE + 1; - else { - shift = new_x / SHIFT_SIZE; - if (new_x % SHIFT_SIZE) - shift--; - } - - if (shift != 0) { - line->shift_count += shift; - new_x = find_x(line, new_address); - set_cursor(0, y); - line_print(line); - rel_x = new_x; - } - } - -/* Assign and position cursor */ - x = new_x; - cur_text = new_address; - cur_line = line; - set_cursor(x, y); -} - -/* - * Find_x() returns the x coordinate belonging to address. - * (Tabs are expanded). - */ -int find_x(line, address) -LINE *line; -char *address; -{ - register char *textp = line->text; - register int nx = get_shift(line->shift_count) * -SHIFT_SIZE; - - while (textp != address && *textp != '\0') { - if (is_tab(*textp++)) /* Expand tabs */ - nx = tab(nx); - else - nx++; - } - return nx; -} - -/* - * Find_address() returns the pointer in the line with offset x_coord. - * (Tabs are expanded). - */ -char *find_address(line, x_coord, old_x) -LINE *line; -int x_coord; -int *old_x; -{ - register char *textp = line->text; - register int tx = get_shift(line->shift_count) * -SHIFT_SIZE; - - while (tx < x_coord && *textp != '\n') { - if (is_tab(*textp)) { - if (*old_x - x_coord == 1 && tab(tx) > x_coord) - break; /* Moving left over tab */ - else - tx = tab(tx); - } - else - tx++; - textp++; - } - - *old_x = tx; - return textp; -} - -/* - * Length_of() returns the number of characters int the string `string' - * excluding the '\0'. - */ -int length_of(string) -register char *string; -{ - register int count = 0; - - if (string != NIL_PTR) { - while (*string++ != '\0') - count++; - } - return count; -} - -/* - * Copy_string() copies the string `from' into the string `to'. `To' must be - * long enough to hold `from'. - */ -void copy_string(to, from) -register char *to; -register char *from; -{ - while (*to++ = *from++) - ; -} - -/* - * Reset assigns bot_line, top_line and cur_line according to `head_line' - * which must be the first line of the screen, and an y-coordinate, - * which will be the current y-coordinate (if it isn't larger than last_y) - */ -void reset(head_line, screen_y) -LINE *head_line; -int screen_y; -{ - register LINE *line; - - top_line = line = head_line; - -/* Search for bot_line (might be last line in file) */ - for (last_y = 0; last_y < nlines - 1 && last_y < screenmax - && line->next != tail; last_y++) - line = line->next; - - bot_line = line; - y = (screen_y > last_y) ? last_y : screen_y; - -/* Set cur_line according to the new y value */ - cur_line = proceed(top_line, y); -} - -/* - * Set cursor at coordinates x, y. - */ -void set_cursor(nx, ny) -int nx, ny; -{ -#ifdef UNIX - extern char *tgoto(); - - tputs(tgoto(CM, nx, ny), 0, _putchar); -#else - char text_buffer[10]; - - build_string(text_buffer, pos_string, ny+1, nx+1); - string_print(text_buffer); -#endif /* UNIX */ -} - -/* - * Routine to open terminal when mined is used in a pipeline. - */ -void open_device() -{ - if ((input_fd = open("/dev/tty", 0)) < 0) - panic("Cannot open /dev/tty for read"); -} - -/* - * Getchar() reads one character from the terminal. The character must be - * masked with 0377 to avoid sign extension. - */ -int getchar() -{ -#ifdef UNIX - return (_getchar() & 0377); -#else - char c; - - if (read(input_fd, &c, 1) != 1 && quit == FALSE) - panic("Can't read one char from fd #0"); - - return c & 0377; -#endif /* UNIX */ -} - -/* - * Display() shows count lines on the terminal starting at the given - * coordinates. When the tail of the list is encountered it will fill the - * rest of the screen with blank_line's. - * When count is negative, a backwards print from `line' will be done. - */ -void display(x_coord, y_coord, line, count) -int x_coord, y_coord; -register LINE *line; -register int count; -{ - set_cursor(x_coord, y_coord); - -/* Find new startline if count is negative */ - if (count < 0) { - line = proceed(line, count); - count = -count; - } - -/* Print the lines */ - while (line != tail && count-- >= 0) { - line_print(line); - line = line->next; - } - -/* Print the blank lines (if any) */ - if (loading == FALSE) { - while (count-- >= 0) { -#ifdef UNIX - tputs(CE, 0, _putchar); -#else - string_print(blank_line); -#endif /* UNIX */ - putchar('\n'); - } - } -} - -/* - * Write_char does a buffered output. - */ -int write_char(fd, c) -int fd; -char c; -{ - screen [out_count++] = c; - if (out_count == SCREEN_SIZE) /* Flush on SCREEN_SIZE chars */ - return flush_buffer(fd); - return FINE; -} - -/* - * Writeline writes the given string on the given filedescriptor. - */ -int writeline(fd, text) -register int fd; -register char *text; -{ - while(*text) - if (write_char(fd, *text++) == ERRORS) - return ERRORS; - return FINE; -} - -/* - * Put_line print the given line on the standard output. If offset is not zero - * printing will start at that x-coordinate. If the FLAG clear_line is TRUE, - * then (screen) line will be cleared when the end of the line has been - * reached. - */ -void put_line(line, offset, clear_line) -LINE *line; /* Line to print */ -int offset; /* Offset to start */ -FLAG clear_line; /* Clear to eoln if TRUE */ -{ - register char *textp = line->text; - register int count = get_shift(line->shift_count) * -SHIFT_SIZE; - int tab_count; /* Used in tab expansion */ - -/* Skip all chars as indicated by the offset and the shift_count field */ - while (count < offset) { - if (is_tab(*textp++)) - count = tab(count); - else - count++; - } - - while (*textp != '\n' && count < XBREAK) { - if (is_tab(*textp)) { /* Expand tabs to spaces */ - tab_count = tab(count); - while (count < XBREAK && count < tab_count) { - count++; - putchar(' '); - } - textp++; - } - else { - if (*textp >= '\01' && *textp <= '\037') { -#ifdef UNIX - tputs(SO, 0, _putchar); -#else - string_print (rev_video); -#endif /* UNIX */ - putchar(*textp++ + '\100'); -#ifdef UNIX - tputs(SE, 0, _putchar); -#else - string_print (normal_video); -#endif /* UNIX */ - } - else - putchar(*textp++); - count++; - } - } - -/* If line is longer than XBREAK chars, print the shift_mark */ - if (count == XBREAK && *textp != '\n') - putchar(textp[1]=='\n' ? *textp : SHIFT_MARK); - -/* Clear the rest of the line is clear_line is TRUE */ - if (clear_line == TRUE) { -#ifdef UNIX - tputs(CE, 0, _putchar); -#else - string_print(blank_line); -#endif /* UNIX */ - putchar('\n'); - } -} - -/* - * Flush the I/O buffer on filedescriptor fd. - */ -int flush_buffer(fd) -int fd; -{ - if (out_count <= 0) /* There is nothing to flush */ - return FINE; -#ifdef UNIX - if (fd == STD_OUT) { - printf("%.*s", out_count, screen); - _flush(); - } - else -#endif /* UNIX */ - if (write(fd, screen, out_count) != out_count) { - bad_write(fd); - return ERRORS; - } - clear_buffer(); /* Empty buffer */ - return FINE; -} - -/* - * Bad_write() is called when a write failed. Notify the user. - */ -void bad_write(fd) -int fd; -{ - if (fd == STD_OUT) /* Cannot write to terminal? */ - exit(1); - - clear_buffer(); - build_string(text_buffer, "Command aborted: %s (File incomplete)", - (errno == ENOSPC || errno == -ENOSPC) ? - "No space on device" : "Write error"); - error(text_buffer, NIL_PTR); -} - -/* - * Catch the SIGQUIT signal (^\) send to mined. It turns on the quitflag. - */ -void catch(sig) -int sig; -{ -/* Reset the signal */ - signal(SIGQUIT, catch); - quit = TRUE; -} - -/* - * Abort_mined() will leave mined. Confirmation is asked first. - */ -void abort_mined() -{ - quit = FALSE; - -/* Ask for confirmation */ - status_line("Really abort? ", NIL_PTR); - if (getchar() != 'y') { - clear_status(); - return; - } - -/* Reset terminal */ - raw_mode(OFF); - set_cursor(0, ymax); - putchar('\n'); - flush(); -#ifdef UNIX - abort(); -#else - exit(1); -#endif /* UNIX */ -} - -#define UNDEF _POSIX_VDISABLE - -/* - * Set and reset tty into CBREAK or old mode according to argument `state'. It - * also sets all signal characters (except for ^\) to UNDEF. ^\ is caught. - */ -void raw_mode(state) -FLAG state; -{ - static struct termios old_tty; - static struct termios new_tty; - - if (state == OFF) { - tcsetattr(input_fd, TCSANOW, &old_tty); - return; - } - -/* Save old tty settings */ - tcgetattr(input_fd, &old_tty); - -/* Set tty to CBREAK mode */ - tcgetattr(input_fd, &new_tty); - new_tty.c_lflag &= ~(ICANON|ECHO|ECHONL); - new_tty.c_iflag &= ~(IXON|IXOFF); - -/* Unset signal chars, leave only SIGQUIT set to ^\ */ - new_tty.c_cc[VINTR] = new_tty.c_cc[VSUSP] = UNDEF; - new_tty.c_cc[VQUIT] = '\\' & 037; - signal(SIGQUIT, catch); /* Which is caught */ - - tcsetattr(input_fd, TCSANOW, &new_tty); -} - -/* - * Panic() is called with an error number and a message. It is called when - * something unrecoverable has happened. - * It writes the message to the terminal, resets the tty and exits. - * Ask the user if he wants to save his file. - */ -void panic(message) -register char *message; -{ - extern char yank_file[]; - -#ifdef UNIX - tputs(CL, 0, _putchar); - build_string(text_buffer, "%s\nError code %d\n", message, errno); -#else - build_string(text_buffer, "%s%s\nError code %d\n", enter_string, message, errno); -#endif /* UNIX */ - (void) write(STD_OUT, text_buffer, length_of(text_buffer)); - - if (loading == FALSE) - XT(); /* Check if file can be saved */ - else - (void) unlink(yank_file); - raw_mode(OFF); - -#ifdef UNIX - abort(); -#else - exit(1); -#endif /* UNIX */ -} - -char *alloc(bytes) -int bytes; -{ - char *p; - - p = malloc((unsigned) bytes); - if (p == NIL_PTR) { - if (loading == TRUE) - panic("File too big."); - panic("Out of memory."); - } - return(p); -} - -void free_space(p) -char *p; -{ - free(p); -} - -/* ======================================================================== * - * Main loops * - * ======================================================================== */ - -/* The mapping between input codes and functions. */ - -void (*key_map[256])() = { /* map ASCII characters to functions */ - /* 000-017 */ MA, BL, MP, YA, SD, RD, MN, IF, DPC, S, S, DT, LR, S, DNW,LIB, - /* 020-037 */ DPW, WB, GR, SH, DLN, SU, VI, XWT, XT, PT, EL, ESC, I, GOTO, - HIGH, LOW, - /* 040-057 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 060-077 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 100-117 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 120-137 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 140-157 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 160-177 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, DCC, - /* 200-217 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 220-237 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 240-257 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 260-277 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 300-317 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 320-337 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 340-357 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, - /* 360-377 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, -}; - -int nlines; /* Number of lines in file */ -LINE *header; /* Head of line list */ -LINE *tail; /* Last line in line list */ -LINE *cur_line; /* Current line in use */ -LINE *top_line; /* First line of screen */ -LINE *bot_line; /* Last line of screen */ -char *cur_text; /* Current char on current line in use */ -int last_y; /* Last y of screen. Usually SCREENMAX */ -char screen[SCREEN_SIZE]; /* Output buffer for "writes" and "reads" */ - -int x, y; /* x, y coordinates on screen */ -FLAG modified = FALSE; /* Set when file is modified */ -FLAG stat_visible; /* Set if status_line is visible */ -FLAG writable; /* Set if file cannot be written */ -FLAG loading; /* Set if we are loading a file. */ -FLAG quit = FALSE; /* Set when quit character is typed */ -FLAG rpipe = FALSE; /* Set if file should be read from stdin */ -int input_fd = 0; /* Fd for command input */ -int out_count; /* Index in output buffer */ -char file_name[LINE_LEN]; /* Name of file in use */ -char text_buffer[MAX_CHARS]; /* Buffer for modifying text */ - -/* Escape sequences. */ -#ifdef UNIX -char *CE, *VS, *SO, *SE, *CL, *AL, *CM; -#else -char *enter_string = "\033[H\033[J"; /* String printed on entering mined */ -char *pos_string = "\033[%d;%dH"; /* Absolute cursor position */ -char *rev_scroll = "\033M"; /* String for reverse scrolling */ -char *rev_video = "\033[7m"; /* String for starting reverse video */ -char *normal_video = "\033[m"; /* String for leaving reverse video */ -char *blank_line = "\033[K"; /* Clear line to end */ -#endif /* UNIX */ - -/* - * Yank variables. - */ -FLAG yank_status = NOT_VALID; /* Status of yank_file */ -char yank_file[] = "/tmp/mined.XXXXXX"; -long chars_saved; /* Nr of chars in buffer */ - -/* - * Initialize is called when a another file is edited. It free's the allocated - * space and sets modified back to FALSE and fixes the header/tail pointer. - */ -void initialize() -{ - register LINE *line, *next_line; - -/* Delete the whole list */ - for (line = header->next; line != tail; line = next_line) { - next_line = line->next; - free_space(line->text); - free_space((char*)line); - } - -/* header and tail should point to itself */ - line->next = line->prev = line; - x = y = 0; - rpipe = modified = FALSE; -} - -/* - * Basename() finds the absolute name of the file out of a given path_name. - */ -char *basename(path) -char *path; -{ - register char *ptr = path; - register char *last = NIL_PTR; - - while (*ptr != '\0') { - if (*ptr == '/') - last = ptr; - ptr++; - } - if (last == NIL_PTR) - return path; - if (*(last + 1) == '\0') { /* E.g. /usr/tmp/pipo/ */ - *last = '\0'; - return basename(path);/* Try again */ - } - return last + 1; -} - -/* - * Load_file loads the file `file' into core. If file is a NIL_PTR or the file - * couldn't be opened, just some initializations are done, and a line consisting - * of a `\n' is installed. - */ -void load_file(file) -char *file; -{ - register LINE *line = header; - register int len; - long nr_of_chars = 0L; - int fd = -1; /* Filedescriptor for file */ - - nlines = 0; /* Zero lines to start with */ - -/* Open file */ - writable = TRUE; /* Benefit of the doubt */ - if (file == NIL_PTR) { - if (rpipe == FALSE) - status_line("No file.", NIL_PTR); - else { - fd = 0; - file = "standard input"; - } - file_name[0] = '\0'; - } - else { - copy_string(file_name, file); /* Save file name */ - if (access(file, 0) < 0) /* Cannot access file. */ - status_line("New file ", file); - else if ((fd = open(file, 0)) < 0) - status_line("Cannot open ", file); - else if (access(file, 2) != 0) /* Set write flag */ - writable = FALSE; - } - -/* Read file */ - loading = TRUE; /* Loading file, so set flag */ - - if (fd >= 0) { - status_line("Reading ", file); - while ((len = get_line(fd, text_buffer)) != ERRORS) { - line = line_insert(line, text_buffer, len); - nr_of_chars += (long) len; - } - if (nlines == 0) /* The file was empty! */ - line = line_insert(line, "\n", 1); - clear_buffer(); /* Clear output buffer */ - cur_line = header->next; - fstatus("Read", nr_of_chars); - (void) close(fd); /* Close file */ - } - else /* Just install a "\n" */ - (void) line_insert(line, "\n", 1); - - reset(header->next, 0); /* Initialize pointers */ - -/* Print screen */ - display (0, 0, header->next, last_y); - move_to (0, 0); - flush(); /* Flush buffer */ - loading = FALSE; /* Stop loading, reset flag */ -} - - -/* - * Get_line reads one line from filedescriptor fd. If EOF is reached on fd, - * get_line() returns ERRORS, else it returns the length of the string. - */ -int get_line(fd, buffer) -int fd; -register char *buffer; -{ - static char *last = NIL_PTR; - static char *current = NIL_PTR; - static int read_chars; - register char *cur_pos = current; - char *begin = buffer; - - do { - if (cur_pos == last) { - if ((read_chars = read(fd, screen, SCREEN_SIZE)) <= 0) - break; - last = &screen[read_chars]; - cur_pos = screen; - } - if (*cur_pos == '\0') - *cur_pos = ' '; - } while ((*buffer++ = *cur_pos++) != '\n'); - - current = cur_pos; - if (read_chars <= 0) { - if (buffer == begin) - return ERRORS; - if (*(buffer - 1) != '\n') - if (loading == TRUE) /* Add '\n' to last line of file */ - *buffer++ = '\n'; - else { - *buffer = '\0'; - return NO_LINE; - } - } - - *buffer = '\0'; - return buffer - begin; -} - -/* - * Install_line installs the buffer into a LINE structure It returns a pointer - * to the allocated structure. - */ -LINE *install_line(buffer, length) -char *buffer; -int length; -{ - register LINE *new_line = (LINE *) alloc(sizeof(LINE)); - - new_line->text = alloc(length + 1); - new_line->shift_count = 0; - copy_string(new_line->text, buffer); - - return new_line; -} - -void main(argc, argv) -int argc; -char *argv[]; -{ -/* mined is the Minix editor. */ - - register int index; /* Index in key table */ - struct winsize winsize; - -#ifdef UNIX - get_term(); - tputs(VS, 0, _putchar); - tputs(CL, 0, _putchar); -#else - string_print(enter_string); /* Hello world */ -#endif /* UNIX */ - if (ioctl(STD_OUT, TIOCGWINSZ, &winsize) == 0 && winsize.ws_row != 0) { - ymax = winsize.ws_row - 1; - screenmax = ymax - 1; - } - - if (!isatty(0)) { /* Reading from pipe */ - if (argc != 1) { - write(2, "Cannot find terminal.\n", 22); - exit (1); - } - rpipe = TRUE; - modified = TRUE; /* Set modified so he can write */ - open_device(); - } - - raw_mode(ON); /* Set tty to appropriate mode */ - - header = tail = (LINE *) alloc(sizeof(LINE)); /* Make header of list*/ - header->text = NIL_PTR; - header->next = tail->prev = header; - -/* Load the file (if any) */ - if (argc < 2) - load_file(NIL_PTR); - else { - (void) get_file(NIL_PTR, argv[1]); /* Truncate filename */ - load_file(argv[1]); - } - - /* Main loop of the editor. */ - for (;;) { - index = getchar(); - if (stat_visible == TRUE) - clear_status(); - if (quit == TRUE) - abort_mined(); - else { /* Call the function for this key */ - (*key_map[index])(index); - flush(); /* Flush output (if any) */ - if (quit == TRUE) - quit = FALSE; - } - } - /* NOTREACHED */ -} - -/* ======================================================================== * - * Miscellaneous * - * ======================================================================== */ - -/* - * Redraw the screen - */ -void RD() -{ -/* Clear screen */ -#ifdef UNIX - tputs(VS, 0, _putchar); - tputs(CL, 0, _putchar); -#else - string_print(enter_string); -#endif /* UNIX */ - -/* Print first page */ - display(0, 0, top_line, last_y); - -/* Clear last line */ - set_cursor(0, ymax); -#ifdef UNIX - tputs(CE, 0, _putchar); -#else - string_print(blank_line); -#endif /* UNIX */ - move_to(x, y); -} - -/* - * Ignore this keystroke. - */ -void I() -{ -} - -/* - * Leave editor. If the file has changed, ask if the user wants to save it. - */ -void XT() -{ - if (modified == TRUE && ask_save() == ERRORS) - return; - - raw_mode(OFF); - set_cursor(0, ymax); - putchar('\n'); - flush(); - (void) unlink(yank_file); /* Might not be necessary */ - exit(0); -} - -void (*escfunc(c))() -int c; -{ -#if (CHIP == M68000) -#ifndef COMPAT - int ch; -#endif -#endif - if (c == '[') { - /* Start of ASCII escape sequence. */ - c = getchar(); -#if (CHIP == M68000) -#ifndef COMPAT - if ((c >= '0') && (c <= '9')) ch = getchar(); - /* ch is either a tilde or a second digit */ -#endif -#endif - switch (c) { - case 'H': return(HO); - case 'A': return(UP); - case 'B': return(DN); - case 'C': return(RT); - case 'D': return(LF); -#if (CHIP == M68000) -#ifndef COMPAT - /* F1 = ESC [ 1 ~ */ - /* F2 = ESC [ 2 ~ */ - /* F3 = ESC [ 3 ~ */ - /* F4 = ESC [ 4 ~ */ - /* F5 = ESC [ 5 ~ */ - /* F6 = ESC [ 6 ~ */ - /* F7 = ESC [ 17 ~ */ - /* F8 = ESC [ 18 ~ */ - case '1': - switch (ch) { - case '~': return(SF); - case '7': (void) getchar(); return(MA); - case '8': (void) getchar(); return(CTL); - } - case '2': return(SR); - case '3': return(PD); - case '4': return(PU); - case '5': return(FS); - case '6': return(EF); -#endif -#endif -#if (CHIP == INTEL) - case 'G': return(FS); - case 'S': return(SR); - case 'T': return(SF); - case 'U': return(PD); - case 'V': return(PU); - case 'Y': return(EF); -#endif - } - return(I); - } -#if (CHIP == M68000) -#ifdef COMPAT - if (c == 'O') { - /* Start of ASCII function key escape sequence. */ - switch (getchar()) { - case 'P': return(SF); - case 'Q': return(SR); - case 'R': return(PD); - case 'S': return(PU); - case 'T': return(FS); - case 'U': return(EF); - case 'V': return(MA); - case 'W': return(CTL); - } - } -#endif -#endif - return(I); -} - -/* - * ESC() wants a count and a command after that. It repeats the - * command count times. If a ^\ is given during repeating, stop looping and - * return to main loop. - */ -void ESC() -{ - register int count = 0; - register void (*func)(); - int index; - - index = getchar(); - while (index >= '0' && index <= '9' && quit == FALSE) { - count *= 10; - count += index - '0'; - index = getchar(); - } - if (count == 0) { - count = 1; - func = escfunc(index); - } else { - func = key_map[index]; - if (func == ESC) - func = escfunc(getchar()); - } - - if (func == I) { /* Function assigned? */ - clear_status(); - return; - } - - while (count-- > 0 && quit == FALSE) { - if (stat_visible == TRUE) - clear_status(); - (*func)(index); - flush(); - } - - if (quit == TRUE) /* Abort has been given */ - error("Aborted", NIL_PTR); -} - -/* - * Ask the user if he wants to save his file or not. - */ -int ask_save() -{ - register int c; - - status_line(file_name[0] ? basename(file_name) : "[buffer]" , - " has been modified. Save? (y/n)"); - - while((c = getchar()) != 'y' && c != 'n' && quit == FALSE) { - ring_bell(); - flush(); - } - - clear_status(); - - if (c == 'y') - return WT(); - - if (c == 'n') - return FINE; - - quit = FALSE; /* Abort character has been given */ - return ERRORS; -} - -/* - * Line_number() finds the line number we're on. - */ -int line_number() -{ - register LINE *line = header->next; - register int count = 1; - - while (line != cur_line) { - count++; - line = line->next; - } - - return count; -} - -/* - * Display a line telling how many chars and lines the file contains. Also tell - * whether the file is readonly and/or modified. - */ -void file_status(message, count, file, lines, writefl, changed) -char *message; -register long count; /* Contains number of characters in file */ -char *file; -int lines; -FLAG writefl, changed; -{ - register LINE *line; - char msg[LINE_LEN + 40];/* Buffer to hold line */ - char yank_msg[LINE_LEN];/* Buffer for msg of yank_file */ - - if (count < 0) /* Not valid. Count chars in file */ - for (line = header->next; line != tail; line = line->next) - count += length_of(line->text); - - if (yank_status != NOT_VALID) /* Append buffer info */ - build_string(yank_msg, " Buffer: %D char%s.", chars_saved, - (chars_saved == 1L) ? "" : "s"); - else - yank_msg[0] = '\0'; - - build_string(msg, "%s %s%s%s %d line%s %D char%s.%s Line %d", message, - (rpipe == TRUE && *message != '[') ? "standard input" : basename(file), - (changed == TRUE) ? "*" : "", - (writefl == FALSE) ? " (Readonly)" : "", - lines, (lines == 1) ? "" : "s", - count, (count == 1L) ? "" : "s", - yank_msg, line_number()); - - if (length_of(msg) + 1 > LINE_LEN - 4) { - msg[LINE_LEN - 4] = SHIFT_MARK; /* Overflow on status line */ - msg[LINE_LEN - 3] = '\0'; - } - status_line(msg, NIL_PTR); /* Print the information */ -} - -/* - * Build_string() prints the arguments as described in fmt, into the buffer. - * %s indicates an argument string, %d indicated an argument number. - */ -#if __STDC__ -void build_string(char *buf, char *fmt, ...) -{ -#else -void build_string(buf, fmt, va_alist) -char *buf, *fmt; -va_dcl -{ -#endif - va_list argptr; - char *scanp; - -#if __STDC__ - va_start(argptr, fmt); -#else - va_start(argptr); -#endif - - while (*fmt) { - if (*fmt == '%') { - fmt++; - switch (*fmt++) { - case 's' : - scanp = va_arg(argptr, char *); - break; - case 'd' : - scanp = num_out((long) va_arg(argptr, int)); - break; - case 'D' : - scanp = num_out((long) va_arg(argptr, long)); - break; - default : - scanp = ""; - } - while (*buf++ = *scanp++) - ; - buf--; - } - else - *buf++ = *fmt++; - } - va_end(argptr); - *buf = '\0'; -} - -/* - * Output an (unsigned) long in a 10 digit field without leading zeros. - * It returns a pointer to the first digit in the buffer. - */ -char *num_out(number) -long number; -{ - static char num_buf[11]; /* Buffer to build number */ - register long digit; /* Next digit of number */ - register long pow = 1000000000L; /* Highest ten power of long */ - FLAG digit_seen = FALSE; - int i; - - for (i = 0; i < 10; i++) { - digit = number / pow; /* Get next digit */ - if (digit == 0L && digit_seen == FALSE && i != 9) - num_buf[i] = ' '; - else { - num_buf[i] = '0' + (char) digit; - number -= digit * pow; /* Erase digit */ - digit_seen = TRUE; - } - pow /= 10L; /* Get next digit */ - } - for (i = 0; num_buf[i] == ' '; i++) /* Skip leading spaces */ - ; - return (&num_buf[i]); -} - -/* - * Get_number() read a number from the terminal. The last character typed in is - * returned. ERRORS is returned on a bad number. The resulting number is put - * into the integer the arguments points to. - */ -int get_number(message, result) -char *message; -int *result; -{ - register int index; - register int count = 0; - - status_line(message, NIL_PTR); - - index = getchar(); - if (quit == FALSE && (index < '0' || index > '9')) { - error("Bad count", NIL_PTR); - return ERRORS; - } - -/* Convert input to a decimal number */ - while (index >= '0' && index <= '9' && quit == FALSE) { - count *= 10; - count += index - '0'; - index = getchar(); - } - - if (quit == TRUE) { - clear_status(); - return ERRORS; - } - - *result = count; - return index; -} - -/* - * Input() reads a string from the terminal. When the KILL character is typed, - * it returns ERRORS. - */ -int input(inbuf, clearfl) -char *inbuf; -FLAG clearfl; -{ - register char *ptr; - register char c; /* Character read */ - - ptr = inbuf; - - *ptr = '\0'; - while (quit == FALSE) { - flush(); - switch (c = getchar()) { - case '\b' : /* Erase previous char */ - if (ptr > inbuf) { - ptr--; -#ifdef UNIX - tputs(SE, 0, _putchar); -#else - string_print(normal_video); -#endif /* UNIX */ - if (is_tab(*ptr)) - string_print(" \b\b\b \b\b"); - else - string_print(" \b\b \b"); -#ifdef UNIX - tputs(SO, 0, _putchar); -#else - string_print(rev_video); -#endif /* UNIX */ - string_print(" \b"); - *ptr = '\0'; - } - else - ring_bell(); - break; - case '\n' : /* End of input */ - /* If inbuf is empty clear status_line */ - return (ptr == inbuf && clearfl == TRUE) ? NO_INPUT :FINE; - default : /* Only read ASCII chars */ - if ((c >= ' ' && c <= '~') || c == '\t') { - *ptr++ = c; - *ptr = '\0'; - if (c == '\t') - string_print("^I"); - else - putchar(c); - string_print(" \b"); - } - else - ring_bell(); - } - } - quit = FALSE; - return ERRORS; -} - -/* - * Get_file() reads a filename from the terminal. Filenames longer than - * FILE_LENGHT chars are truncated. - */ -int get_file(message, file) -char *message, *file; -{ - char *ptr; - int ret; - - if (message == NIL_PTR || (ret = get_string(message, file, TRUE)) == FINE) { - if (length_of((ptr = basename(file))) > NAME_MAX) - ptr[NAME_MAX] = '\0'; - } - return ret; -} - -/* ======================================================================== * - * UNIX I/O Routines * - * ======================================================================== */ - -#ifdef UNIX -#undef putchar - -int _getchar() -{ - char c; - - if (read(input_fd, &c, 1) != 1 && quit == FALSE) - panic ("Cannot read 1 byte from input"); - return c & 0377; -} - -void _flush() -{ - (void) fflush(stdout); -} - -void _putchar(c) -char c; -{ - (void) write_char(STD_OUT, c); -} - -void get_term() -{ - static char termbuf[50]; - extern char *tgetstr(), *getenv(); - char *loc = termbuf; - char entry[1024]; - - if (tgetent(entry, getenv("TERM")) <= 0) { - printf("Unknown terminal.\n"); - exit(1); - } - - AL = tgetstr("al", &loc); - CE = tgetstr("ce", &loc); - VS = tgetstr("vs", &loc); - CL = tgetstr("cl", &loc); - SO = tgetstr("so", &loc); - SE = tgetstr("se", &loc); - CM = tgetstr("cm", &loc); - ymax = tgetnum("li") - 1; - screenmax = ymax - 1; - - if (!CE || !SO || !SE || !CL || !AL || !CM) { - printf("Sorry, no mined on this type of terminal\n"); - exit(1); - } -} -#endif /* UNIX */ diff --git a/languages/ruby/being_rescue_else_ensure.rb b/languages/ruby/being_rescue_else_ensure.rb deleted file mode 100644 index 53eaee1f..00000000 --- a/languages/ruby/being_rescue_else_ensure.rb +++ /dev/null @@ -1,11 +0,0 @@ -begin - puts "Hello, world!" - 1/0 -rescue => e - puts e - puts "rescue" -else - puts "else" -ensure - puts "ensure" -end diff --git a/languages/ruby/check_nil.rb b/languages/ruby/check_nil.rb deleted file mode 100644 index ea3653d3..00000000 --- a/languages/ruby/check_nil.rb +++ /dev/null @@ -1,6 +0,0 @@ -if true.nil? - print "true" -else - print "false" -end - diff --git a/languages/ruby/class_and_object.rb b/languages/ruby/class_and_object.rb deleted file mode 100644 index 079bb4bf..00000000 --- a/languages/ruby/class_and_object.rb +++ /dev/null @@ -1,22 +0,0 @@ -class Rectangle - def initialize(length, breadth) - @length = length - @breadth = breadth - end - - def perimeter - 2 * (@length + @breadth) - end - - def area - @length * @breadth - end -end - -rect = Rectangle.new(10, - 20) - -# In ruby, you initialize an object using the new method -# -puts rect.perimeter -puts rect.area diff --git a/languages/ruby/conditionals.rb b/languages/ruby/conditionals.rb deleted file mode 100644 index 336f8dec..00000000 --- a/languages/ruby/conditionals.rb +++ /dev/null @@ -1,4 +0,0 @@ -closeit = false -puts "close it" if closeit -closeit = true -puts "does not closes it" if closedit diff --git a/languages/ruby/constant_assignment.rb b/languages/ruby/constant_assignment.rb deleted file mode 100644 index 1a69d354..00000000 --- a/languages/ruby/constant_assignment.rb +++ /dev/null @@ -1,2 +0,0 @@ -MY_CONST = 1 -MY_CONST = 2 # generates a warning diff --git a/languages/ruby/forloop.rb b/languages/ruby/forloop.rb deleted file mode 100644 index 33358695..00000000 --- a/languages/ruby/forloop.rb +++ /dev/null @@ -1,4 +0,0 @@ -array = [1, 2, 3, 4, 5] -for i in array - puts i -end diff --git a/languages/ruby/handle_exceptions.rb b/languages/ruby/handle_exceptions.rb deleted file mode 100644 index 9899fed8..00000000 --- a/languages/ruby/handle_exceptions.rb +++ /dev/null @@ -1,16 +0,0 @@ -class NewTypeError < ArgumentError -end - -def inverse(x) - begin - raise NewTypeError, 'Argument is not numeric' unless x.is_a? Numeric - rescue SecurityError =>e - puts "it is a security error" - rescue ArgumentError => e - puts e.message - puts e.backtrace.inspect - end -end - -inverse(2) -inverse('not a number') diff --git a/languages/ruby/if_statement.rb b/languages/ruby/if_statement.rb deleted file mode 100644 index 60a657b7..00000000 --- a/languages/ruby/if_statement.rb +++ /dev/null @@ -1,5 +0,0 @@ -something = true - -if something == true - puts "something" -end diff --git a/languages/ruby/include_modules.rb b/languages/ruby/include_modules.rb deleted file mode 100644 index 55c0cfa8..00000000 --- a/languages/ruby/include_modules.rb +++ /dev/null @@ -1,2 +0,0 @@ -require "ruby15.rb" -RubyModule::rubyfunction(10) diff --git a/languages/ruby/introspect.rb b/languages/ruby/introspect.rb deleted file mode 100644 index 32d530cc..00000000 --- a/languages/ruby/introspect.rb +++ /dev/null @@ -1,20 +0,0 @@ -module Debug - def whoAmI? - "#{self.type.name} (\##{self.id}): #{self.to_s}" - end -end -class Phonograph - include Debug - # ... -end -class EightTrack - include Debug - # ... -end - -# Gives ArgumentError - Has something happened in the Ruby version? - -ph = Phonograph.new("West End Blues") -et = EightTrack.new("Surrealistic Pillow") -p ph.whoAmI? -p et.whoAmI? diff --git a/languages/ruby/iterate_each.rb b/languages/ruby/iterate_each.rb deleted file mode 100644 index 89bd7b8a..00000000 --- a/languages/ruby/iterate_each.rb +++ /dev/null @@ -1,4 +0,0 @@ -array = [1, 2, 3, 4, 5, 6] -array.each do |i| - puts i -end diff --git a/languages/ruby/kernel_method.rb b/languages/ruby/kernel_method.rb deleted file mode 100644 index 74b7d9fb..00000000 --- a/languages/ruby/kernel_method.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Kernel - def canonical - puts "hello, world" - end -end diff --git a/languages/ruby/module_mixin.rb b/languages/ruby/module_mixin.rb deleted file mode 100644 index 45807930..00000000 --- a/languages/ruby/module_mixin.rb +++ /dev/null @@ -1,18 +0,0 @@ -# Ruby module Mixin example. - -module Debug - def whoAmI? - "#{self.type.name} (\##{self.id}): " - end -end -class Phonograph - include Debug -end -class EightTrack - include Debug - -end -ph = Phonograph.new -et = EightTrack.new -ph.whoAmI? # "Phonograph (#537766170): West End Blues" -et.whoAmI? # "EightTrack (#537765860): Surrealistic Pillow" diff --git a/languages/ruby/modules_with_methods.rb b/languages/ruby/modules_with_methods.rb deleted file mode 100644 index 47ef3a9c..00000000 --- a/languages/ruby/modules_with_methods.rb +++ /dev/null @@ -1,45 +0,0 @@ -module Debug - def whoAmI? - "#{self.type.name} (\##{self.id}): #{self.to_s}" - end -end -class Phonograph - include Debug - - def initialize(title) - @title = title - end - def type - self.class - end - def id - self.object_id - end - def to_s - @title - end -end -class EightTrack - include Debug - - def initialize(title) - @title = title - end - - def type - self.class - end - - def id - self.object_id - end - - def to_s - @title - end -end - -ph = Phonograph.new("West End Blues") -et = EightTrack.new("Surrealistic Pillow") -p ph.whoAmI? -p et.whoAmI? diff --git a/languages/ruby/open_url.rb b/languages/ruby/open_url.rb deleted file mode 100644 index 406c4661..00000000 --- a/languages/ruby/open_url.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "open-uri" - -open("http://www.uthcode.com") do |lost| - puts lost.read -end diff --git a/languages/ruby/puts_examples.rb b/languages/ruby/puts_examples.rb deleted file mode 100644 index 1fd549f7..00000000 --- a/languages/ruby/puts_examples.rb +++ /dev/null @@ -1,7 +0,0 @@ -puts "Hello World!" -puts "Hello Again" -puts "I like typing this." -puts "This is fun." -puts 'Yay! Printing.' -puts "I'd much rather you 'not'." -puts 'I "said" do not touch this.' diff --git a/languages/ruby/puts_functionname.rb b/languages/ruby/puts_functionname.rb deleted file mode 100644 index e0cdc749..00000000 --- a/languages/ruby/puts_functionname.rb +++ /dev/null @@ -1,6 +0,0 @@ -def somefunction - x = "something" - y = x -end -x = somefunction -p x diff --git a/languages/ruby/require_stmt.rb b/languages/ruby/require_stmt.rb deleted file mode 100644 index f4ee057d..00000000 --- a/languages/ruby/require_stmt.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'rubygems' -gem 'RedCloth' diff --git a/languages/ruby/ruby13.rb b/languages/ruby/ruby13.rb deleted file mode 100644 index e0b26a5b..00000000 --- a/languages/ruby/ruby13.rb +++ /dev/null @@ -1,2 +0,0 @@ -p $: -p File.expand_path("../", __FILE__) diff --git a/languages/ruby/ruby16.rb b/languages/ruby/ruby16.rb deleted file mode 100644 index 55c0cfa8..00000000 --- a/languages/ruby/ruby16.rb +++ /dev/null @@ -1,2 +0,0 @@ -require "ruby15.rb" -RubyModule::rubyfunction(10) diff --git a/languages/ruby/ruby5.rb b/languages/ruby/ruby5.rb deleted file mode 100644 index b3ae9ca7..00000000 --- a/languages/ruby/ruby5.rb +++ /dev/null @@ -1,7 +0,0 @@ -#!/opt/twitter/rvm/rubies/ruby-1.9.3-p194/bin/ruby - -puts :'I love Ruby!' -puts :'I love Ruby!.'.to_i - -# ruby5.rb:4:in `
': undefined method `to_i' for :"I love Ruby!.":Symbol (NoMethodError) -# diff --git a/languages/ruby/ruby7.rb b/languages/ruby/ruby7.rb deleted file mode 100644 index 79cd91b8..00000000 --- a/languages/ruby/ruby7.rb +++ /dev/null @@ -1,6 +0,0 @@ -at_hotel = true -email = if at_hotel do - address = "something" - address << "new address" - address << "updated address" - end diff --git a/languages/ruby/ruby_function.rb b/languages/ruby/ruby_function.rb deleted file mode 100644 index da64fde6..00000000 --- a/languages/ruby/ruby_function.rb +++ /dev/null @@ -1,7 +0,0 @@ -module RubyModule - def rubyfunction(num) - puts "within rubyfunction" - puts num - end - module_function :rubyfunction -end diff --git a/languages/ruby/see_backtrace.rb b/languages/ruby/see_backtrace.rb deleted file mode 100644 index a066642c..00000000 --- a/languages/ruby/see_backtrace.rb +++ /dev/null @@ -1,13 +0,0 @@ -def a - raise "boom" -end - -def b - a() -end - -begin - b() -rescue => detail - print detail.backtrace.join("\n") -end diff --git a/languages/ruby/simpleNumber.rb b/languages/ruby/simpleNumber.rb deleted file mode 100644 index 6e17c549..00000000 --- a/languages/ruby/simpleNumber.rb +++ /dev/null @@ -1,14 +0,0 @@ -class SimpleNumber - def initialize(num) - raise unless num.is_a?(Numeric) - @x = num - end - - def add(y) - @x + y - end - - def multiply(y) - @x * y - end -end diff --git a/languages/ruby/string_methods.rb b/languages/ruby/string_methods.rb deleted file mode 100644 index 8cb1317f..00000000 --- a/languages/ruby/string_methods.rb +++ /dev/null @@ -1,4 +0,0 @@ -puts :senthil -puts :senthil.to_s -puts :senthil.class -puts :senthil.to_i diff --git a/languages/ruby/string_templates.rb b/languages/ruby/string_templates.rb deleted file mode 100644 index 4bc37df6..00000000 --- a/languages/ruby/string_templates.rb +++ /dev/null @@ -1,3 +0,0 @@ -name = "senthil" -age = 31 -puts "Hello, my name is #{name} and I am #{age} years old!" diff --git a/languages/ruby/string_times.rb b/languages/ruby/string_times.rb deleted file mode 100644 index be93cb88..00000000 --- a/languages/ruby/string_times.rb +++ /dev/null @@ -1 +0,0 @@ -5.times do print "something" end diff --git a/languages/ruby/tc_simpleNumber.rb b/languages/ruby/tc_simpleNumber.rb deleted file mode 100644 index ad5b0004..00000000 --- a/languages/ruby/tc_simpleNumber.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "simpleNumber" -require "test/unit" - -class TestSimpleNumber < Test::Unit::TestCase - def test_simple - assert_equal(4, SimpleNumber.new(2).add(2)) - assert_equal(6, SimpleNumber.new(2).multiply(3)) - end -end diff --git a/source/index.rst b/source/index.rst index 68259f03..9d51f3fe 100644 --- a/source/index.rst +++ b/source/index.rst @@ -42,14 +42,6 @@ Python Programming Language python/index -Ruby Programming Language -========================= - -.. toctree:: - :maxdepth: 3 - - ruby/index - Java Programming Language ========================= diff --git a/source/ruby/being_rescue_else_ensure.rst b/source/ruby/being_rescue_else_ensure.rst deleted file mode 100644 index 26304aaa..00000000 --- a/source/ruby/being_rescue_else_ensure.rst +++ /dev/null @@ -1,34 +0,0 @@ -======================== -Being Rescue Else Ensure -======================== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/being_rescue_else_ensure.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/being_rescue_else_ensure.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`being_rescue_else_ensure.rb` - * :ruby-better-explain:`being_rescue_else_ensure.rst` - diff --git a/source/ruby/check_nil.rst b/source/ruby/check_nil.rst deleted file mode 100644 index c6a461a4..00000000 --- a/source/ruby/check_nil.rst +++ /dev/null @@ -1,34 +0,0 @@ -========= -Check Nil -========= - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/check_nil.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/check_nil.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`check_nil.rb` - * :ruby-better-explain:`check_nil.rst` - diff --git a/source/ruby/class_and_object.rst b/source/ruby/class_and_object.rst deleted file mode 100644 index 05d1f2ae..00000000 --- a/source/ruby/class_and_object.rst +++ /dev/null @@ -1,34 +0,0 @@ -================ -Class And Object -================ - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/class_and_object.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/class_and_object.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`class_and_object.rb` - * :ruby-better-explain:`class_and_object.rst` - diff --git a/source/ruby/conditionals.rst b/source/ruby/conditionals.rst deleted file mode 100644 index 6d8defd7..00000000 --- a/source/ruby/conditionals.rst +++ /dev/null @@ -1,34 +0,0 @@ -============ -Conditionals -============ - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/conditionals.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/conditionals.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`conditionals.rb` - * :ruby-better-explain:`conditionals.rst` - diff --git a/source/ruby/constant_assignment.rst b/source/ruby/constant_assignment.rst deleted file mode 100644 index 87069daa..00000000 --- a/source/ruby/constant_assignment.rst +++ /dev/null @@ -1,34 +0,0 @@ -=================== -Constant Assignment -=================== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/constant_assignment.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/constant_assignment.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`constant_assignment.rb` - * :ruby-better-explain:`constant_assignment.rst` - diff --git a/source/ruby/forloop.rst b/source/ruby/forloop.rst deleted file mode 100644 index 4e2d04f0..00000000 --- a/source/ruby/forloop.rst +++ /dev/null @@ -1,32 +0,0 @@ -========= -For loops -========= - -Demonstrate the for loop in Ruby. - -Solution --------- - -.. literalinclude:: ../../languages/ruby/forloop.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/forloop.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - -Iterating using the construct `for x in container` will iterate through the -values of the array. - - - - - -.. seealso:: - - * :ruby-suggest-improve:`forloop.rb` - * :ruby-better-explain:`forloop.rst` - diff --git a/source/ruby/handle_exceptions.rst b/source/ruby/handle_exceptions.rst deleted file mode 100644 index 3b310ca1..00000000 --- a/source/ruby/handle_exceptions.rst +++ /dev/null @@ -1,34 +0,0 @@ -================= -Handle Exceptions -================= - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/handle_exceptions.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/handle_exceptions.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`handle_exceptions.rb` - * :ruby-better-explain:`handle_exceptions.rst` - diff --git a/source/ruby/if_statement.rst b/source/ruby/if_statement.rst deleted file mode 100644 index e71c0a11..00000000 --- a/source/ruby/if_statement.rst +++ /dev/null @@ -1,35 +0,0 @@ -============ -If Statement -============ - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/if_statement.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/if_statement.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`if_statement.rb` - * :ruby-better-explain:`if_statement.rst` - - diff --git a/source/ruby/include_modules.rst b/source/ruby/include_modules.rst deleted file mode 100644 index f61a6f12..00000000 --- a/source/ruby/include_modules.rst +++ /dev/null @@ -1,35 +0,0 @@ -=============== -Include Modules -=============== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/include_modules.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/include_modules.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`include_modules.rb` - * :ruby-better-explain:`include_modules.rst` - - diff --git a/source/ruby/index.rst b/source/ruby/index.rst deleted file mode 100644 index f14a7461..00000000 --- a/source/ruby/index.rst +++ /dev/null @@ -1,43 +0,0 @@ -========================= -Ruby Programming Examples -========================= - -Ruby programming section, illustrates how to do various programing tasks using -Ruby programming language. - -Common Programming Tasks -======================== -This is an implementation of a well known CS algorithm. - -.. toctree:: - :maxdepth: 1 - - being_rescue_else_ensure - check_nil - class_and_object - conditionals - constant_assignment - forloop - handle_exceptions - if_statement - include_modules - introspect - iterate_each - kernel_method - module_mixin - modules_with_methods - open_url - puts_examples - puts_functionname - require_stmt - ruby_function - ruby5 - ruby7 - ruby13 - ruby16 - see_backtrace - simpleNumber - string_methods - string_templates - string_times - tc_simpleNumber \ No newline at end of file diff --git a/source/ruby/introspect.rst b/source/ruby/introspect.rst deleted file mode 100644 index b48d61de..00000000 --- a/source/ruby/introspect.rst +++ /dev/null @@ -1,35 +0,0 @@ -========== -Introspect -========== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/introspect.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/introspect.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`introspect.rb` - * :ruby-better-explain:`introspect.rst` - - diff --git a/source/ruby/iterate_each.rst b/source/ruby/iterate_each.rst deleted file mode 100644 index c062b35d..00000000 --- a/source/ruby/iterate_each.rst +++ /dev/null @@ -1,35 +0,0 @@ -============ -Iterate Each -============ - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/iterate_each.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/iterate_each.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`iterate_each.rb` - * :ruby-better-explain:`iterate_each.rst` - - diff --git a/source/ruby/kernel_method.rst b/source/ruby/kernel_method.rst deleted file mode 100644 index 172a8161..00000000 --- a/source/ruby/kernel_method.rst +++ /dev/null @@ -1,35 +0,0 @@ -============= -Kernel Method -============= - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/kernel_method.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/kernel_method.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`kernel_method.rb` - * :ruby-better-explain:`kernel_method.rst` - - diff --git a/source/ruby/module_mixin.rst b/source/ruby/module_mixin.rst deleted file mode 100644 index 5c3f6439..00000000 --- a/source/ruby/module_mixin.rst +++ /dev/null @@ -1,33 +0,0 @@ -============ -Module Mixin -============ - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/module_mixin.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/module_mixin.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`module_mixin.rb` - * :ruby-better-explain:`module_mixin.rst` diff --git a/source/ruby/modules_with_methods.rst b/source/ruby/modules_with_methods.rst deleted file mode 100644 index 3294027f..00000000 --- a/source/ruby/modules_with_methods.rst +++ /dev/null @@ -1,35 +0,0 @@ -==================== -Modules With Methods -==================== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/modules_with_methods.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/modules_with_methods.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`modules_with_methods.rb` - * :ruby-better-explain:`modules_with_methods.rst` - - diff --git a/source/ruby/open_url.rst b/source/ruby/open_url.rst deleted file mode 100644 index 79ea258d..00000000 --- a/source/ruby/open_url.rst +++ /dev/null @@ -1,35 +0,0 @@ -======== -Open URL -======== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/open_url.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/open_url.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`open_url.rb` - * :ruby-better-explain:`open_url.rst` - - diff --git a/source/ruby/puts_examples.rst b/source/ruby/puts_examples.rst deleted file mode 100644 index 484000fc..00000000 --- a/source/ruby/puts_examples.rst +++ /dev/null @@ -1,35 +0,0 @@ -============= -Puts Examples -============= - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/puts_examples.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/puts_examples.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`puts_examples.rb` - * :ruby-better-explain:`puts_examples.rst` - - diff --git a/source/ruby/puts_functionname.rst b/source/ruby/puts_functionname.rst deleted file mode 100644 index 550903af..00000000 --- a/source/ruby/puts_functionname.rst +++ /dev/null @@ -1,35 +0,0 @@ -================= -Puts Functionname -================= - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/puts_functionname.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/puts_functionname.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`puts_functionname.rb` - * :ruby-better-explain:`puts_functionname.rst` - - diff --git a/source/ruby/require_stmt.rst b/source/ruby/require_stmt.rst deleted file mode 100644 index 908ea516..00000000 --- a/source/ruby/require_stmt.rst +++ /dev/null @@ -1,35 +0,0 @@ -================= -Require Statement -================= - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/require_stmt.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/require_stmt.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`require_stmt.rb` - * :ruby-better-explain:`require_stmt.rst` - - diff --git a/source/ruby/ruby13.rst b/source/ruby/ruby13.rst deleted file mode 100644 index 662042f7..00000000 --- a/source/ruby/ruby13.rst +++ /dev/null @@ -1,35 +0,0 @@ -====== -Ruby13 -====== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/ruby13.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/ruby13.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`ruby13.rb` - * :ruby-better-explain:`ruby13.rst` - - diff --git a/source/ruby/ruby16.rst b/source/ruby/ruby16.rst deleted file mode 100644 index 9f801fab..00000000 --- a/source/ruby/ruby16.rst +++ /dev/null @@ -1,35 +0,0 @@ -====== -Ruby16 -====== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/ruby16.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/ruby16.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`ruby16.rb` - * :ruby-better-explain:`ruby16.rst` - - diff --git a/source/ruby/ruby5.rst b/source/ruby/ruby5.rst deleted file mode 100644 index b510ff56..00000000 --- a/source/ruby/ruby5.rst +++ /dev/null @@ -1,35 +0,0 @@ -===== -Ruby5 -===== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/ruby5.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/ruby5.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`ruby5.rb` - * :ruby-better-explain:`ruby5.rst` - - diff --git a/source/ruby/ruby7.rst b/source/ruby/ruby7.rst deleted file mode 100644 index 9971d473..00000000 --- a/source/ruby/ruby7.rst +++ /dev/null @@ -1,35 +0,0 @@ -===== -Ruby7 -===== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/ruby7.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/ruby7.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`ruby7.rb` - * :ruby-better-explain:`ruby7.rst` - - diff --git a/source/ruby/ruby_function.rst b/source/ruby/ruby_function.rst deleted file mode 100644 index 2da91288..00000000 --- a/source/ruby/ruby_function.rst +++ /dev/null @@ -1,35 +0,0 @@ -============= -Ruby Function -============= - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/ruby_function.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/ruby_function.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`ruby_function.rb` - * :ruby-better-explain:`ruby_function.rst` - - diff --git a/source/ruby/see_backtrace.rst b/source/ruby/see_backtrace.rst deleted file mode 100644 index 7083cf68..00000000 --- a/source/ruby/see_backtrace.rst +++ /dev/null @@ -1,35 +0,0 @@ -============== -See Back Trace -============== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/see_backtrace.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/see_backtrace.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`see_backtrace.rb` - * :ruby-better-explain:`see_backtrace.rst` - - diff --git a/source/ruby/simpleNumber.rst b/source/ruby/simpleNumber.rst deleted file mode 100644 index 7e21db6d..00000000 --- a/source/ruby/simpleNumber.rst +++ /dev/null @@ -1,35 +0,0 @@ -============= -Simple Number -============= - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/simpleNumber.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/simpleNumber.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`simpleNumber.rb` - * :ruby-better-explain:`simpleNumber.rst` - - diff --git a/source/ruby/string_methods.rst b/source/ruby/string_methods.rst deleted file mode 100644 index f948614a..00000000 --- a/source/ruby/string_methods.rst +++ /dev/null @@ -1,35 +0,0 @@ -============== -String Methods -============== - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/string_methods.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/string_methods.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`string_methods.rb` - * :ruby-better-explain:`string_methods.rst` - - diff --git a/source/ruby/string_templates.rst b/source/ruby/string_templates.rst deleted file mode 100644 index 28bd516e..00000000 --- a/source/ruby/string_templates.rst +++ /dev/null @@ -1,35 +0,0 @@ -================ -String Templates -================ - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/string_templates.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/string_templates.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`string_templates.rb` - * :ruby-better-explain:`string_templates.rst` - - diff --git a/source/ruby/string_times.rst b/source/ruby/string_times.rst deleted file mode 100644 index d2f94549..00000000 --- a/source/ruby/string_times.rst +++ /dev/null @@ -1,35 +0,0 @@ -============ -String Times -============ - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/string_times.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/string_times.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`string_times.rb` - * :ruby-better-explain:`string_times.rst` - - diff --git a/source/ruby/tc_simpleNumber.rst b/source/ruby/tc_simpleNumber.rst deleted file mode 100644 index fd4729b1..00000000 --- a/source/ruby/tc_simpleNumber.rst +++ /dev/null @@ -1,35 +0,0 @@ -================ -Tc Simple Number -================ - -Question --------- - -ADDQUESTION - -Solution --------- - -.. literalinclude:: ../../languages/ruby/tc_simpleNumber.rb - :language: ruby - :tab-width: 4 - -.. runcode:: ../../languages/ruby/tc_simpleNumber.rb - :language: ruby - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :ruby-suggest-improve:`tc_simpleNumber.rb` - * :ruby-better-explain:`tc_simpleNumber.rst` - - From 5de22f46662f650d1fa9249fc126eeb9d03b67c0 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Wed, 6 Jan 2021 07:25:54 -0800 Subject: [PATCH 002/244] Removed Java from source and programs. --- languages/java/AbstractClass.java | 60 ------ languages/java/AlignNumbers.java | 14 -- languages/java/AligningStrings.java | 9 - languages/java/AllPathsTryCatchFinally.java | 27 --- languages/java/AnimatedCanvas.java | 35 ---- languages/java/ArithmeticOperators.java | 18 -- languages/java/ArrayAssignmentTypeCheck.java | 21 -- languages/java/AssignmentNoCopyObjects.java | 35 ---- languages/java/AutoBoxingUnboxing.java | 35 ---- languages/java/BinaryOutput.java | 60 ------ languages/java/BinarySearchSortedArray.java | 29 --- languages/java/BitwiseOperators.java | 24 --- languages/java/BlockStatements.java | 33 --- languages/java/BuildingConcordance.java | 49 ----- languages/java/CallingNonOverloaded.java | 60 ------ languages/java/CallingOverloaded.java | 39 ---- .../java/CallingOverriddenConstructor.java | 41 ---- languages/java/CallingOverriden.java | 58 ------ languages/java/ClassesInterfaces.java | 71 ------- languages/java/Comments.java | 14 -- languages/java/CompleteInputOutput.java | 21 -- languages/java/CompoundAssignment.java | 18 -- languages/java/ConcatCliArgs.java | 11 - languages/java/Concatenate.java | 12 -- languages/java/ConcordanceUsingIterables.java | 49 ----- languages/java/ConcreteCollection.java | 76 ------- languages/java/ConditionalExpression.java | 15 -- languages/java/ConstraintsType.java | 36 ---- languages/java/ConstructorOverloading.java | 30 --- languages/java/ConversionPrimitive.java | 25 --- languages/java/CountEs.java | 16 -- languages/java/DeclaringCheckedException.java | 28 --- languages/java/Describe.java | 28 --- languages/java/DoWhileRollaDie.java | 18 -- languages/java/EmptyStatement.java | 13 -- languages/java/EnhancedForStatement.java | 12 -- languages/java/EqualityStrings.java | 20 -- languages/java/EqualsMethod.java | 40 ---- languages/java/ExplicitIterable.java | 53 ----- languages/java/ExplicitIterableWhileLoop.java | 57 ------ languages/java/FieldAccess.java | 67 ------ languages/java/FieldDeclarations.java | 28 --- languages/java/FieldInitializers.java | 28 --- languages/java/FloatingPointFactorial.java | 16 -- languages/java/ForStatementIterable.java | 47 ----- languages/java/FormattingDateAndTime.java | 12 -- languages/java/GaussianPseudoRandom.java | 17 -- languages/java/GenericArrayLists.java | 24 --- languages/java/GenericClassLogging.java | 48 ----- languages/java/GenericClassType.java | 31 --- languages/java/GenericInterfaceFunction.java | 27 --- languages/java/GenericLinkedList.java | 103 ---------- languages/java/GenericList.java | 24 --- languages/java/GenericMethodGenericClass.java | 107 ---------- languages/java/GenericQuickSort.java | 49 ----- .../java/GenericQuicksortComparable.java | 40 ---- languages/java/GenericsLimitation.java | 34 ---- languages/java/HelloUnicode.java | 10 - languages/java/HelloWorld.java | 5 - languages/java/IfTest.java | 9 - languages/java/InefficientReplacement.java | 24 --- languages/java/InitializedArray.java | 17 -- languages/java/InnerObjects.java | 32 --- languages/java/InputOutputExamples.java | 86 -------- languages/java/InsertionSort.java | 34 ---- languages/java/IntegerComparator.java | 51 ----- languages/java/InternalPipes.java | 43 ---- languages/java/IterationOverIterable.java | 25 --- languages/java/IteratorAnonymous.java | 36 ---- languages/java/JavaFiveFeatures.java | 55 ----- languages/java/Layout.java | 50 ----- languages/java/Lexicographic.java | 15 -- .../java/LinkedHashSetRemoveDuplicates.java | 20 -- languages/java/LocalInnerClassInterator.java | 39 ---- languages/java/LocaleSpecificDate.java | 15 -- languages/java/LocaleSpecificNumbers.java | 13 -- languages/java/LogicalOperators.java | 21 -- languages/java/MathematicalFunctions.java | 34 ---- languages/java/MemberAccessModifiers.java | 7 - languages/java/MemberClasses.java | 39 ---- languages/java/MethodNameOverloading.java | 28 --- languages/java/MethodOverloadingHiding.java | 51 ----- .../java/MethodOverloadingParameterArray.java | 24 --- languages/java/MethodReturningIterable.java | 45 ----- languages/java/MultiDimensionalArray.java | 27 --- languages/java/MultipleThreads.java | 26 --- languages/java/MutualExclusion.java | 43 ---- languages/java/NestedForLoops.java | 12 -- languages/java/NonGenericArrayList.java | 30 --- languages/java/ObjectCreation.java | 14 -- languages/java/ObjectsAndClasses.java | 6 - languages/java/ObjectsWithMultipleFields.java | 6 - languages/java/ObtainedSubMap.java | 49 ----- languages/java/OneDimensionalArray.java | 29 --- languages/java/OutputBuffering.java | 39 ---- languages/java/PaddingString.java | 16 -- languages/java/ParameterPassing.java | 45 ----- languages/java/Point.java | 27 --- languages/java/PrintHTMLTable.java | 20 -- languages/java/PrintingNumbers.java | 25 --- languages/java/PrivateMemberAccess.java | 19 -- languages/java/ProducerConsumer.java | 41 ---- languages/java/RandomAccessReads.java | 27 --- languages/java/ReadingNumbers.java | 30 --- languages/java/ReadingNumbersLineByLine.java | 31 --- .../java/ReadingPrintingDirHierarchy.java | 27 --- languages/java/ReflectionPublicMethods.java | 50 ----- languages/java/ReflectiveAccessToField.java | 48 ----- languages/java/ReflectiveCreation.java | 49 ----- languages/java/ReflectiveInspection.java | 51 ----- languages/java/ReflectiveObjectCreation.java | 47 ----- languages/java/ReflectiveRetrieval.java | 50 ----- languages/java/ReplaceOccurances.java | 18 -- languages/java/RepresentingWeekdays.java | 58 ------ languages/java/Scope.java | 31 --- languages/java/SequenceIfElse.java | 20 -- .../java/SerializationDistinctObject.java | 63 ------ languages/java/SerializationSameObject.java | 58 ------ languages/java/SetMembership.java | 21 -- languages/java/SetsKeysinHashMap.java | 28 --- languages/java/SeveralFieldsSameName.java | 33 --- languages/java/SingleIfElse.java | 17 -- languages/java/SocketCommunication.java | 56 ----- languages/java/SpecifyingOutputEncoding.java | 19 -- languages/java/StoringResultsDatabase.java | 40 ---- languages/java/StringArrayFile.java | 73 ------- languages/java/StringComparator.java | 55 ----- languages/java/StringFromCharArray.java | 25 --- languages/java/SubtypeRelations.java | 42 ---- languages/java/SuperclassConstructor.java | 27 --- languages/java/SwitchOnEnum.java | 27 --- languages/java/SwitchStatement.java | 25 --- languages/java/SwitchStatementStrings.java | 42 ---- languages/java/SynchronizedMethods.java | 58 ------ languages/java/ThreeInterfaces.java | 21 -- languages/java/ThrowingExceptionFailure.java | 29 --- languages/java/TimeComparable.java | 39 ---- languages/java/ToString.java | 34 ---- languages/java/TopLevelClass.java | 48 ----- languages/java/TreeSetRange.java | 20 -- languages/java/TryCatch.java | 34 ---- languages/java/TryFinally.java | 38 ---- languages/java/TypeErasure.java | 22 -- languages/java/TypeParameter.java | 28 --- languages/java/UncheckedCast.java | 25 --- .../UnderstandingCollectionsbinarySearch.java | 6 - .../java/UnderstandingCollectionscopy.java | 6 - languages/java/UniqueClassObject.java | 53 ----- languages/java/UsingAppendableInterface.java | 66 ------ languages/java/UsingBreakToExitLabeled.java | 19 -- languages/java/UsingBreakToTerminateLoop.java | 21 -- .../java/UsingContinueStartIteration.java | 21 -- languages/java/UsingCustomAnnotation.java | 87 -------- languages/java/UsingInterfacesAsTypes.java | 31 --- .../java/UsingMultidimentionalArrays.java | 41 ---- .../java/UsingReturntoTerminateLoop.java | 22 -- languages/java/Usingassert.java | 30 --- .../java/UsingassertsCheckAlgorithm.java | 25 --- languages/java/Usingthis.java | 19 -- languages/java/UsingthisObject.java | 33 --- languages/java/VariableDeclaration.java | 21 -- languages/java/VesselHeirarchy.java | 90 --------- .../java/WeekdayNametoNumberHashMap.java | 24 --- languages/java/WhileLoop.java | 29 --- languages/java/WideningNarrowing.java | 16 -- languages/java/WildcardTypes.java | 30 --- languages/java/WorklistAlgorithm.java | 38 ---- languages/java/tryFinally.txt | 3 - source/index.rst | 8 - source/java/AbstractClass.rst | 32 --- source/java/AlignNumbers.rst | 31 --- source/java/AligningStrings.rst | 34 ---- source/java/AllPathsTryCatchFinally.rst | 34 ---- source/java/AnimatedCanvas.rst | 34 ---- source/java/ArithmeticOperators.rst | 34 ---- source/java/ArrayAssignmentTypeCheck.rst | 34 ---- source/java/AssignmentNoCopyObjects.rst | 34 ---- source/java/AutoBoxingUnboxing.rst | 34 ---- source/java/BinaryOutput.rst | 34 ---- source/java/BinarySearchSortedArray.rst | 34 ---- source/java/BitwiseOperators.rst | 34 ---- source/java/BlockStatements.rst | 34 ---- source/java/BuildingConcordance.rst | 34 ---- source/java/CallingNonOverloaded.rst | 34 ---- source/java/CallingOverloaded.rst | 34 ---- source/java/CallingOverriddenConstructor.rst | 34 ---- source/java/CallingOverriden.rst | 34 ---- source/java/ClassesInterfaces.rst | 34 ---- source/java/Comments.rst | 34 ---- source/java/CompleteInputOutput.rst | 34 ---- source/java/CompoundAssignment.rst | 34 ---- source/java/ConcatCliArgs.rst | 34 ---- source/java/Concatenate.rst | 34 ---- source/java/ConcordanceUsingIterables.rst | 34 ---- source/java/ConcreteCollection.rst | 34 ---- source/java/ConditionalExpression.rst | 34 ---- source/java/ConstraintsType.rst | 34 ---- source/java/ConstructorOverloading.rst | 34 ---- source/java/ConversionPrimitive.rst | 34 ---- source/java/CountEs.rst | 34 ---- source/java/DeclaringCheckedException.rst | 34 ---- source/java/Describe.rst | 34 ---- source/java/DoWhileRollaDie.rst | 34 ---- source/java/EmptyStatement.rst | 34 ---- source/java/EnhancedForStatement.rst | 34 ---- source/java/EqualityStrings.rst | 34 ---- source/java/EqualsMethod.rst | 34 ---- source/java/ExplicitIterable.rst | 34 ---- source/java/ExplicitIterableWhileLoop.rst | 34 ---- source/java/FieldAccess.rst | 34 ---- source/java/FieldDeclarations.rst | 34 ---- source/java/FieldInitializers.rst | 34 ---- source/java/FloatingPointFactorial.rst | 34 ---- source/java/ForStatementIterable.rst | 34 ---- source/java/FormattingDateAndTime.rst | 34 ---- source/java/GaussianPseudoRandom.rst | 34 ---- source/java/GenericArrayLists.rst | 34 ---- source/java/GenericClassLogging.rst | 34 ---- source/java/GenericClassType.rst | 34 ---- source/java/GenericInterfaceFunction.rst | 34 ---- source/java/GenericLinkedList.rst | 34 ---- source/java/GenericList.rst | 34 ---- source/java/GenericMethodGenericClass.rst | 34 ---- source/java/GenericQuickSort.rst | 34 ---- source/java/GenericQuicksortComparable.rst | 34 ---- source/java/GenericsLimitation.rst | 34 ---- source/java/HelloUnicode.rst | 34 ---- source/java/HelloWorld.rst | 34 ---- source/java/IfTest.rst | 34 ---- source/java/InefficientReplacement.rst | 34 ---- source/java/InitializedArray.rst | 34 ---- source/java/InnerObjects.rst | 34 ---- source/java/InputOutputExamples.rst | 34 ---- source/java/IntegerComparator.rst | 34 ---- source/java/InternalPipes.rst | 34 ---- source/java/IterationOverIterable.rst | 34 ---- source/java/IteratorAnonymous.rst | 34 ---- source/java/JavaFiveFeatures.rst | 34 ---- source/java/Layout.rst | 34 ---- source/java/Lexicographic.rst | 34 ---- source/java/LinkedHashSetRemoveDuplicates.rst | 34 ---- source/java/LocalInnerClassInterator.rst | 34 ---- source/java/LocaleSpecificDate.rst | 34 ---- source/java/LocaleSpecificNumbers.rst | 34 ---- source/java/LogicalOperators.rst | 34 ---- source/java/MathematicalFunctions.rst | 34 ---- source/java/MemberAccessModifiers.rst | 34 ---- source/java/MemberClasses.rst | 34 ---- source/java/MethodNameOverloading.rst | 34 ---- source/java/MethodOverloadingHiding.rst | 34 ---- .../java/MethodOverloadingParameterArray.rst | 34 ---- source/java/MethodReturningIterable.rst | 34 ---- source/java/MultiDimensionalArray.rst | 34 ---- source/java/MultipleThreads.rst | 34 ---- source/java/MutualExclusion.rst | 34 ---- source/java/NestedForLoops.rst | 34 ---- source/java/NonGenericArrayList.rst | 34 ---- source/java/ObjectCreation.rst | 34 ---- source/java/ObjectsAndClasses.rst | 34 ---- source/java/ObjectsWithMultipleFields.rst | 34 ---- source/java/ObtainedSubMap.rst | 34 ---- source/java/OneDimensionalArray.rst | 34 ---- source/java/OutputBuffering.rst | 34 ---- source/java/PaddingString.rst | 34 ---- source/java/ParameterPassing.rst | 34 ---- source/java/Point.rst | 34 ---- source/java/PrintHTMLTable.rst | 34 ---- source/java/PrintingNumbers.rst | 34 ---- source/java/PrivateMemberAccess.rst | 34 ---- source/java/ProducerConsumer.rst | 34 ---- source/java/RandomAccessReads.rst | 34 ---- source/java/ReadingNumbers.rst | 34 ---- source/java/ReadingNumbersLineByLine.rst | 34 ---- source/java/ReadingPrintingDirHierarchy.rst | 34 ---- source/java/ReflectionPublicMethods.rst | 34 ---- source/java/ReflectiveAccessToField.rst | 34 ---- source/java/ReflectiveCreation.rst | 34 ---- source/java/ReflectiveInspection.rst | 34 ---- source/java/ReflectiveObjectCreation.rst | 34 ---- source/java/ReflectiveRetrieval.rst | 34 ---- source/java/ReplaceOccurances.rst | 34 ---- source/java/RepresentingWeekdays.rst | 34 ---- source/java/Scope.rst | 34 ---- source/java/SequenceIfElse.rst | 34 ---- source/java/SerializationDistinctObject.rst | 34 ---- source/java/SerializationSameObject.rst | 34 ---- source/java/SetMembership.rst | 34 ---- source/java/SetsKeysinHashMap.rst | 35 ---- source/java/SeveralFieldsSameName.rst | 34 ---- source/java/SingleIfElse.rst | 34 ---- source/java/SocketCommunication.rst | 34 ---- source/java/SpecifyingOutputEncoding.rst | 34 ---- source/java/StoringResultsDatabase.rst | 34 ---- source/java/StringArrayFile.rst | 34 ---- source/java/StringComparator.rst | 34 ---- source/java/StringFromCharArray.rst | 34 ---- source/java/SubtypeRelations.rst | 34 ---- source/java/SuperclassConstructor.rst | 34 ---- source/java/SwitchOnEnum.rst | 34 ---- source/java/SwitchStatement.rst | 34 ---- source/java/SwitchStatementStrings.rst | 34 ---- source/java/SynchronizedMethods.rst | 34 ---- source/java/ThreeInterfaces.rst | 34 ---- source/java/ThrowingExceptionFailure.rst | 34 ---- source/java/TimeComparable.rst | 34 ---- source/java/ToString.rst | 34 ---- source/java/TopLevelClass.rst | 34 ---- source/java/TreeSetRange.rst | 34 ---- source/java/TryCatch.rst | 34 ---- source/java/TryFinally.rst | 34 ---- source/java/TypeErasure.rst | 34 ---- source/java/TypeParameter.rst | 34 ---- source/java/UncheckedCast.rst | 34 ---- .../UnderstandingCollectionsbinarySearch.rst | 34 ---- source/java/UnderstandingCollectionscopy.rst | 34 ---- source/java/UniqueClassObject.rst | 34 ---- source/java/UsingAppendableInterface.rst | 34 ---- source/java/UsingBreakToExitLabeled.rst | 34 ---- source/java/UsingBreakToTerminateLoop.rst | 33 --- source/java/UsingContinueStartIteration.rst | 34 ---- source/java/UsingCustomAnnotation.rst | 34 ---- source/java/UsingInterfacesAsTypes.rst | 34 ---- source/java/UsingMultidimentionalArrays.rst | 34 ---- source/java/UsingReturntoTerminateLoop.rst | 34 ---- source/java/Usingassert.rst | 34 ---- source/java/UsingassertsCheckAlgorithm.rst | 34 ---- source/java/Usingthis.rst | 34 ---- source/java/UsingthisObject.rst | 34 ---- source/java/VariableDeclaration.rst | 34 ---- source/java/VesselHeirarchy.rst | 34 ---- source/java/WeekdayNametoNumberHashMap.rst | 34 ---- source/java/WhileLoop.rst | 34 ---- source/java/WideningNarrowing.rst | 34 ---- source/java/WildcardTypes.rst | 34 ---- source/java/WorklistAlgorithm.rst | 34 ---- source/java/index.rst | 191 ------------------ 336 files changed, 11467 deletions(-) delete mode 100644 languages/java/AbstractClass.java delete mode 100644 languages/java/AlignNumbers.java delete mode 100644 languages/java/AligningStrings.java delete mode 100644 languages/java/AllPathsTryCatchFinally.java delete mode 100644 languages/java/AnimatedCanvas.java delete mode 100644 languages/java/ArithmeticOperators.java delete mode 100644 languages/java/ArrayAssignmentTypeCheck.java delete mode 100644 languages/java/AssignmentNoCopyObjects.java delete mode 100644 languages/java/AutoBoxingUnboxing.java delete mode 100644 languages/java/BinaryOutput.java delete mode 100644 languages/java/BinarySearchSortedArray.java delete mode 100644 languages/java/BitwiseOperators.java delete mode 100644 languages/java/BlockStatements.java delete mode 100644 languages/java/BuildingConcordance.java delete mode 100644 languages/java/CallingNonOverloaded.java delete mode 100644 languages/java/CallingOverloaded.java delete mode 100644 languages/java/CallingOverriddenConstructor.java delete mode 100644 languages/java/CallingOverriden.java delete mode 100644 languages/java/ClassesInterfaces.java delete mode 100644 languages/java/Comments.java delete mode 100644 languages/java/CompleteInputOutput.java delete mode 100644 languages/java/CompoundAssignment.java delete mode 100644 languages/java/ConcatCliArgs.java delete mode 100644 languages/java/Concatenate.java delete mode 100644 languages/java/ConcordanceUsingIterables.java delete mode 100644 languages/java/ConcreteCollection.java delete mode 100644 languages/java/ConditionalExpression.java delete mode 100644 languages/java/ConstraintsType.java delete mode 100644 languages/java/ConstructorOverloading.java delete mode 100644 languages/java/ConversionPrimitive.java delete mode 100644 languages/java/CountEs.java delete mode 100644 languages/java/DeclaringCheckedException.java delete mode 100644 languages/java/Describe.java delete mode 100644 languages/java/DoWhileRollaDie.java delete mode 100644 languages/java/EmptyStatement.java delete mode 100644 languages/java/EnhancedForStatement.java delete mode 100644 languages/java/EqualityStrings.java delete mode 100644 languages/java/EqualsMethod.java delete mode 100644 languages/java/ExplicitIterable.java delete mode 100644 languages/java/ExplicitIterableWhileLoop.java delete mode 100644 languages/java/FieldAccess.java delete mode 100644 languages/java/FieldDeclarations.java delete mode 100644 languages/java/FieldInitializers.java delete mode 100644 languages/java/FloatingPointFactorial.java delete mode 100644 languages/java/ForStatementIterable.java delete mode 100644 languages/java/FormattingDateAndTime.java delete mode 100644 languages/java/GaussianPseudoRandom.java delete mode 100644 languages/java/GenericArrayLists.java delete mode 100644 languages/java/GenericClassLogging.java delete mode 100644 languages/java/GenericClassType.java delete mode 100644 languages/java/GenericInterfaceFunction.java delete mode 100644 languages/java/GenericLinkedList.java delete mode 100644 languages/java/GenericList.java delete mode 100644 languages/java/GenericMethodGenericClass.java delete mode 100644 languages/java/GenericQuickSort.java delete mode 100644 languages/java/GenericQuicksortComparable.java delete mode 100644 languages/java/GenericsLimitation.java delete mode 100644 languages/java/HelloUnicode.java delete mode 100644 languages/java/HelloWorld.java delete mode 100644 languages/java/IfTest.java delete mode 100644 languages/java/InefficientReplacement.java delete mode 100644 languages/java/InitializedArray.java delete mode 100644 languages/java/InnerObjects.java delete mode 100644 languages/java/InputOutputExamples.java delete mode 100644 languages/java/InsertionSort.java delete mode 100644 languages/java/IntegerComparator.java delete mode 100644 languages/java/InternalPipes.java delete mode 100644 languages/java/IterationOverIterable.java delete mode 100644 languages/java/IteratorAnonymous.java delete mode 100644 languages/java/JavaFiveFeatures.java delete mode 100644 languages/java/Layout.java delete mode 100644 languages/java/Lexicographic.java delete mode 100644 languages/java/LinkedHashSetRemoveDuplicates.java delete mode 100644 languages/java/LocalInnerClassInterator.java delete mode 100644 languages/java/LocaleSpecificDate.java delete mode 100644 languages/java/LocaleSpecificNumbers.java delete mode 100644 languages/java/LogicalOperators.java delete mode 100644 languages/java/MathematicalFunctions.java delete mode 100644 languages/java/MemberAccessModifiers.java delete mode 100644 languages/java/MemberClasses.java delete mode 100644 languages/java/MethodNameOverloading.java delete mode 100644 languages/java/MethodOverloadingHiding.java delete mode 100644 languages/java/MethodOverloadingParameterArray.java delete mode 100644 languages/java/MethodReturningIterable.java delete mode 100644 languages/java/MultiDimensionalArray.java delete mode 100644 languages/java/MultipleThreads.java delete mode 100644 languages/java/MutualExclusion.java delete mode 100644 languages/java/NestedForLoops.java delete mode 100644 languages/java/NonGenericArrayList.java delete mode 100644 languages/java/ObjectCreation.java delete mode 100644 languages/java/ObjectsAndClasses.java delete mode 100644 languages/java/ObjectsWithMultipleFields.java delete mode 100644 languages/java/ObtainedSubMap.java delete mode 100644 languages/java/OneDimensionalArray.java delete mode 100644 languages/java/OutputBuffering.java delete mode 100644 languages/java/PaddingString.java delete mode 100644 languages/java/ParameterPassing.java delete mode 100644 languages/java/Point.java delete mode 100644 languages/java/PrintHTMLTable.java delete mode 100644 languages/java/PrintingNumbers.java delete mode 100644 languages/java/PrivateMemberAccess.java delete mode 100644 languages/java/ProducerConsumer.java delete mode 100644 languages/java/RandomAccessReads.java delete mode 100644 languages/java/ReadingNumbers.java delete mode 100644 languages/java/ReadingNumbersLineByLine.java delete mode 100644 languages/java/ReadingPrintingDirHierarchy.java delete mode 100644 languages/java/ReflectionPublicMethods.java delete mode 100644 languages/java/ReflectiveAccessToField.java delete mode 100644 languages/java/ReflectiveCreation.java delete mode 100644 languages/java/ReflectiveInspection.java delete mode 100644 languages/java/ReflectiveObjectCreation.java delete mode 100644 languages/java/ReflectiveRetrieval.java delete mode 100644 languages/java/ReplaceOccurances.java delete mode 100644 languages/java/RepresentingWeekdays.java delete mode 100644 languages/java/Scope.java delete mode 100644 languages/java/SequenceIfElse.java delete mode 100644 languages/java/SerializationDistinctObject.java delete mode 100644 languages/java/SerializationSameObject.java delete mode 100644 languages/java/SetMembership.java delete mode 100644 languages/java/SetsKeysinHashMap.java delete mode 100644 languages/java/SeveralFieldsSameName.java delete mode 100644 languages/java/SingleIfElse.java delete mode 100644 languages/java/SocketCommunication.java delete mode 100644 languages/java/SpecifyingOutputEncoding.java delete mode 100644 languages/java/StoringResultsDatabase.java delete mode 100644 languages/java/StringArrayFile.java delete mode 100644 languages/java/StringComparator.java delete mode 100644 languages/java/StringFromCharArray.java delete mode 100644 languages/java/SubtypeRelations.java delete mode 100644 languages/java/SuperclassConstructor.java delete mode 100644 languages/java/SwitchOnEnum.java delete mode 100644 languages/java/SwitchStatement.java delete mode 100644 languages/java/SwitchStatementStrings.java delete mode 100644 languages/java/SynchronizedMethods.java delete mode 100644 languages/java/ThreeInterfaces.java delete mode 100644 languages/java/ThrowingExceptionFailure.java delete mode 100644 languages/java/TimeComparable.java delete mode 100644 languages/java/ToString.java delete mode 100644 languages/java/TopLevelClass.java delete mode 100644 languages/java/TreeSetRange.java delete mode 100644 languages/java/TryCatch.java delete mode 100644 languages/java/TryFinally.java delete mode 100644 languages/java/TypeErasure.java delete mode 100644 languages/java/TypeParameter.java delete mode 100644 languages/java/UncheckedCast.java delete mode 100644 languages/java/UnderstandingCollectionsbinarySearch.java delete mode 100644 languages/java/UnderstandingCollectionscopy.java delete mode 100644 languages/java/UniqueClassObject.java delete mode 100644 languages/java/UsingAppendableInterface.java delete mode 100644 languages/java/UsingBreakToExitLabeled.java delete mode 100644 languages/java/UsingBreakToTerminateLoop.java delete mode 100644 languages/java/UsingContinueStartIteration.java delete mode 100644 languages/java/UsingCustomAnnotation.java delete mode 100644 languages/java/UsingInterfacesAsTypes.java delete mode 100644 languages/java/UsingMultidimentionalArrays.java delete mode 100644 languages/java/UsingReturntoTerminateLoop.java delete mode 100644 languages/java/Usingassert.java delete mode 100644 languages/java/UsingassertsCheckAlgorithm.java delete mode 100644 languages/java/Usingthis.java delete mode 100644 languages/java/UsingthisObject.java delete mode 100644 languages/java/VariableDeclaration.java delete mode 100644 languages/java/VesselHeirarchy.java delete mode 100644 languages/java/WeekdayNametoNumberHashMap.java delete mode 100644 languages/java/WhileLoop.java delete mode 100644 languages/java/WideningNarrowing.java delete mode 100644 languages/java/WildcardTypes.java delete mode 100644 languages/java/WorklistAlgorithm.java delete mode 100644 languages/java/tryFinally.txt delete mode 100644 source/java/AbstractClass.rst delete mode 100644 source/java/AlignNumbers.rst delete mode 100644 source/java/AligningStrings.rst delete mode 100644 source/java/AllPathsTryCatchFinally.rst delete mode 100644 source/java/AnimatedCanvas.rst delete mode 100644 source/java/ArithmeticOperators.rst delete mode 100644 source/java/ArrayAssignmentTypeCheck.rst delete mode 100644 source/java/AssignmentNoCopyObjects.rst delete mode 100644 source/java/AutoBoxingUnboxing.rst delete mode 100644 source/java/BinaryOutput.rst delete mode 100644 source/java/BinarySearchSortedArray.rst delete mode 100644 source/java/BitwiseOperators.rst delete mode 100644 source/java/BlockStatements.rst delete mode 100644 source/java/BuildingConcordance.rst delete mode 100644 source/java/CallingNonOverloaded.rst delete mode 100644 source/java/CallingOverloaded.rst delete mode 100644 source/java/CallingOverriddenConstructor.rst delete mode 100644 source/java/CallingOverriden.rst delete mode 100644 source/java/ClassesInterfaces.rst delete mode 100644 source/java/Comments.rst delete mode 100644 source/java/CompleteInputOutput.rst delete mode 100644 source/java/CompoundAssignment.rst delete mode 100644 source/java/ConcatCliArgs.rst delete mode 100644 source/java/Concatenate.rst delete mode 100644 source/java/ConcordanceUsingIterables.rst delete mode 100644 source/java/ConcreteCollection.rst delete mode 100644 source/java/ConditionalExpression.rst delete mode 100644 source/java/ConstraintsType.rst delete mode 100644 source/java/ConstructorOverloading.rst delete mode 100644 source/java/ConversionPrimitive.rst delete mode 100644 source/java/CountEs.rst delete mode 100644 source/java/DeclaringCheckedException.rst delete mode 100644 source/java/Describe.rst delete mode 100644 source/java/DoWhileRollaDie.rst delete mode 100644 source/java/EmptyStatement.rst delete mode 100644 source/java/EnhancedForStatement.rst delete mode 100644 source/java/EqualityStrings.rst delete mode 100644 source/java/EqualsMethod.rst delete mode 100644 source/java/ExplicitIterable.rst delete mode 100644 source/java/ExplicitIterableWhileLoop.rst delete mode 100644 source/java/FieldAccess.rst delete mode 100644 source/java/FieldDeclarations.rst delete mode 100644 source/java/FieldInitializers.rst delete mode 100644 source/java/FloatingPointFactorial.rst delete mode 100644 source/java/ForStatementIterable.rst delete mode 100644 source/java/FormattingDateAndTime.rst delete mode 100644 source/java/GaussianPseudoRandom.rst delete mode 100644 source/java/GenericArrayLists.rst delete mode 100644 source/java/GenericClassLogging.rst delete mode 100644 source/java/GenericClassType.rst delete mode 100644 source/java/GenericInterfaceFunction.rst delete mode 100644 source/java/GenericLinkedList.rst delete mode 100644 source/java/GenericList.rst delete mode 100644 source/java/GenericMethodGenericClass.rst delete mode 100644 source/java/GenericQuickSort.rst delete mode 100644 source/java/GenericQuicksortComparable.rst delete mode 100644 source/java/GenericsLimitation.rst delete mode 100644 source/java/HelloUnicode.rst delete mode 100644 source/java/HelloWorld.rst delete mode 100644 source/java/IfTest.rst delete mode 100644 source/java/InefficientReplacement.rst delete mode 100644 source/java/InitializedArray.rst delete mode 100644 source/java/InnerObjects.rst delete mode 100644 source/java/InputOutputExamples.rst delete mode 100644 source/java/IntegerComparator.rst delete mode 100644 source/java/InternalPipes.rst delete mode 100644 source/java/IterationOverIterable.rst delete mode 100644 source/java/IteratorAnonymous.rst delete mode 100644 source/java/JavaFiveFeatures.rst delete mode 100644 source/java/Layout.rst delete mode 100644 source/java/Lexicographic.rst delete mode 100644 source/java/LinkedHashSetRemoveDuplicates.rst delete mode 100644 source/java/LocalInnerClassInterator.rst delete mode 100644 source/java/LocaleSpecificDate.rst delete mode 100644 source/java/LocaleSpecificNumbers.rst delete mode 100644 source/java/LogicalOperators.rst delete mode 100644 source/java/MathematicalFunctions.rst delete mode 100644 source/java/MemberAccessModifiers.rst delete mode 100644 source/java/MemberClasses.rst delete mode 100644 source/java/MethodNameOverloading.rst delete mode 100644 source/java/MethodOverloadingHiding.rst delete mode 100644 source/java/MethodOverloadingParameterArray.rst delete mode 100644 source/java/MethodReturningIterable.rst delete mode 100644 source/java/MultiDimensionalArray.rst delete mode 100644 source/java/MultipleThreads.rst delete mode 100644 source/java/MutualExclusion.rst delete mode 100644 source/java/NestedForLoops.rst delete mode 100644 source/java/NonGenericArrayList.rst delete mode 100644 source/java/ObjectCreation.rst delete mode 100644 source/java/ObjectsAndClasses.rst delete mode 100644 source/java/ObjectsWithMultipleFields.rst delete mode 100644 source/java/ObtainedSubMap.rst delete mode 100644 source/java/OneDimensionalArray.rst delete mode 100644 source/java/OutputBuffering.rst delete mode 100644 source/java/PaddingString.rst delete mode 100644 source/java/ParameterPassing.rst delete mode 100644 source/java/Point.rst delete mode 100644 source/java/PrintHTMLTable.rst delete mode 100644 source/java/PrintingNumbers.rst delete mode 100644 source/java/PrivateMemberAccess.rst delete mode 100644 source/java/ProducerConsumer.rst delete mode 100644 source/java/RandomAccessReads.rst delete mode 100644 source/java/ReadingNumbers.rst delete mode 100644 source/java/ReadingNumbersLineByLine.rst delete mode 100644 source/java/ReadingPrintingDirHierarchy.rst delete mode 100644 source/java/ReflectionPublicMethods.rst delete mode 100644 source/java/ReflectiveAccessToField.rst delete mode 100644 source/java/ReflectiveCreation.rst delete mode 100644 source/java/ReflectiveInspection.rst delete mode 100644 source/java/ReflectiveObjectCreation.rst delete mode 100644 source/java/ReflectiveRetrieval.rst delete mode 100644 source/java/ReplaceOccurances.rst delete mode 100644 source/java/RepresentingWeekdays.rst delete mode 100644 source/java/Scope.rst delete mode 100644 source/java/SequenceIfElse.rst delete mode 100644 source/java/SerializationDistinctObject.rst delete mode 100644 source/java/SerializationSameObject.rst delete mode 100644 source/java/SetMembership.rst delete mode 100644 source/java/SetsKeysinHashMap.rst delete mode 100644 source/java/SeveralFieldsSameName.rst delete mode 100644 source/java/SingleIfElse.rst delete mode 100644 source/java/SocketCommunication.rst delete mode 100644 source/java/SpecifyingOutputEncoding.rst delete mode 100644 source/java/StoringResultsDatabase.rst delete mode 100644 source/java/StringArrayFile.rst delete mode 100644 source/java/StringComparator.rst delete mode 100644 source/java/StringFromCharArray.rst delete mode 100644 source/java/SubtypeRelations.rst delete mode 100644 source/java/SuperclassConstructor.rst delete mode 100644 source/java/SwitchOnEnum.rst delete mode 100644 source/java/SwitchStatement.rst delete mode 100644 source/java/SwitchStatementStrings.rst delete mode 100644 source/java/SynchronizedMethods.rst delete mode 100644 source/java/ThreeInterfaces.rst delete mode 100644 source/java/ThrowingExceptionFailure.rst delete mode 100644 source/java/TimeComparable.rst delete mode 100644 source/java/ToString.rst delete mode 100644 source/java/TopLevelClass.rst delete mode 100644 source/java/TreeSetRange.rst delete mode 100644 source/java/TryCatch.rst delete mode 100644 source/java/TryFinally.rst delete mode 100644 source/java/TypeErasure.rst delete mode 100644 source/java/TypeParameter.rst delete mode 100644 source/java/UncheckedCast.rst delete mode 100644 source/java/UnderstandingCollectionsbinarySearch.rst delete mode 100644 source/java/UnderstandingCollectionscopy.rst delete mode 100644 source/java/UniqueClassObject.rst delete mode 100644 source/java/UsingAppendableInterface.rst delete mode 100644 source/java/UsingBreakToExitLabeled.rst delete mode 100644 source/java/UsingBreakToTerminateLoop.rst delete mode 100644 source/java/UsingContinueStartIteration.rst delete mode 100644 source/java/UsingCustomAnnotation.rst delete mode 100644 source/java/UsingInterfacesAsTypes.rst delete mode 100644 source/java/UsingMultidimentionalArrays.rst delete mode 100644 source/java/UsingReturntoTerminateLoop.rst delete mode 100644 source/java/Usingassert.rst delete mode 100644 source/java/UsingassertsCheckAlgorithm.rst delete mode 100644 source/java/Usingthis.rst delete mode 100644 source/java/UsingthisObject.rst delete mode 100644 source/java/VariableDeclaration.rst delete mode 100644 source/java/VesselHeirarchy.rst delete mode 100644 source/java/WeekdayNametoNumberHashMap.rst delete mode 100644 source/java/WhileLoop.rst delete mode 100644 source/java/WideningNarrowing.rst delete mode 100644 source/java/WildcardTypes.rst delete mode 100644 source/java/WorklistAlgorithm.rst delete mode 100644 source/java/index.rst diff --git a/languages/java/AbstractClass.java b/languages/java/AbstractClass.java deleted file mode 100644 index 03bd7c0e..00000000 --- a/languages/java/AbstractClass.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Example 27 - Abstract Classes, Subclasses, and Overriding - */ -class AbstractClass { - - abstract class Vessel { - double contents; - abstract double capacity(); - void fill(double amount) { - contents = Math.min(contents + amount, capacity()); - } - } - - class Tank extends Vessel { - - double length, width, height; - - Tank(double length, double width, double height) { - this.length = length; - this.width = width; - this.height = height; - } - - double capacity() { - return length * width * height; - } - - public String toString() { - return "tank (" + length + ", " + width + ", " + height + ")"; - } - } - - class Cube extends Tank { - - Cube(double side) { - super(side, side, side); - } - - public String toString() { - return "cube (" + length + ")"; - } - } - - class Barrel extends Vessel { - double radius, height; - - Barrel(double radius, double height) { - this.radius = radius; - this.height = height; - } - - double capacity() { - return height * Math.PI * radius * radius; - } - - public String toString() { - return "barrel (" + radius + ", " + height + ")"; - } - } -} diff --git a/languages/java/AlignNumbers.java b/languages/java/AlignNumbers.java deleted file mode 100644 index 4faa724e..00000000 --- a/languages/java/AlignNumbers.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.Random; - -/** - * Example 14 - Aligning Numbers in Columns using out.format - */ -class AlignNumbers { - public static void main(String[] args) { - Random rnd = new Random(); - for (int i = 0; i < 3; i++) - for (int j = 0; j <5; j++) - System.out.format("%4d", rnd.nextInt(1000)); - System.out.format("%n"); - } -} diff --git a/languages/java/AligningStrings.java b/languages/java/AligningStrings.java deleted file mode 100644 index 44d80293..00000000 --- a/languages/java/AligningStrings.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Example 13 - Aligning Strings Using String.format Method - */ -class AligningStrings { - public static void main(String[] args) { - String res = String.format("|%1$s|%1$15s|%1$-15s|", "Uthcode"); - System.out.println(res); - } -} diff --git a/languages/java/AllPathsTryCatchFinally.java b/languages/java/AllPathsTryCatchFinally.java deleted file mode 100644 index 93e42d35..00000000 --- a/languages/java/AllPathsTryCatchFinally.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Example 90 - All Paths Through a try-catch-finally Statement - */ -class AllPathsTryCatchFinally { - - public static void main(String[] args) throws Exception{ - System.out.println(m(Integer.parseInt(args[0]))); - } - - static String m(int a) throws Exception { - try { - System.out.println("try ..."); - if (a/100 == 2) return "returned from try"; - if (a/100 == 3) throw new Exception("thrown by try"); - if (a/100 == 4) throw new RuntimeException("thrown by a try"); - } catch (RuntimeException x) { - System.out.println("catch ..."); - if (a/10%10 == 2) return "returned from catch"; - if (a/10%10 == 3) throw new Exception("thrown by catch"); - } finally { - System.out.println("finally"); - if (a%10 == 2) return "returned from finally"; - if (a%10 == 3) throw new Exception("thrown by finally"); - } - return "terminated normally with " + a; - } -} diff --git a/languages/java/AnimatedCanvas.java b/languages/java/AnimatedCanvas.java deleted file mode 100644 index 9b502f08..00000000 --- a/languages/java/AnimatedCanvas.java +++ /dev/null @@ -1,35 +0,0 @@ -import javax.swing.*; -import java.awt.*; - -/** - * Example 95 - Graphic Animation Using the Runnable Interface - */ -class AnimatedCanvas extends Canvas implements Runnable{ - - AnimatedCanvas() { - Thread u = new Thread(this); - u.start(); - } - - @Override - public void run() { - for(;;){ - try { - Thread.sleep(100); - } catch (InterruptedException e) {} - repaint(); - } - } - - public void paint(Graphics g) { - g.drawString("Hello World", 200, 200); - } - - public static void main(String[] args) { - AnimatedCanvas animatedCanvas = new AnimatedCanvas(); - JFrame jp = new JFrame(); - jp.getContentPane().add(animatedCanvas, BorderLayout.CENTER); - jp.setSize(new Dimension(500,500)); - jp.setVisible(true); - } -} diff --git a/languages/java/ArithmeticOperators.java b/languages/java/ArithmeticOperators.java deleted file mode 100644 index 340551a4..00000000 --- a/languages/java/ArithmeticOperators.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Example 45 - Arithmetic Operators - */ -class ArithmeticOperators { - - public static void main(String[] args) { - int max = 2147483647; - int min = -2147483638; - System.out.println(max+1); - System.out.println(min-1); - System.out.print(10 / 3); - System.out.println(10/(-3)); - System.out.print(10 % 3); - System.out.println(10%(-3)); - System.out.print((-10) % 3); - System.out.println((-10) % (-3)); - } -} diff --git a/languages/java/ArrayAssignmentTypeCheck.java b/languages/java/ArrayAssignmentTypeCheck.java deleted file mode 100644 index 8872b8cd..00000000 --- a/languages/java/ArrayAssignmentTypeCheck.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Example 19 - Array Element Assignment Type Check at Run-Time - */ -public class ArrayAssignmentTypeCheck { - - public static void main(String[] args) { - Number[] a = new Integer[10]; - Double d = new Double(3.14); - Integer i = new Integer(117); - Number n = i; - a[0] = i; - a[1] = n; - // Results in a Runtime exception - try { - a[2] = d; - } catch (ArrayStoreException e) { - System.out.println("Caught an ArrayStoreException."); - } - } - -} diff --git a/languages/java/AssignmentNoCopyObjects.java b/languages/java/AssignmentNoCopyObjects.java deleted file mode 100644 index 39ca6fa4..00000000 --- a/languages/java/AssignmentNoCopyObjects.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Example 49 - Assignment Does Not Copy Objects - */ -class AssignmentNoCopyObjects { - - static class Point { - int x; - int y; - - Point(int x, int y) { - this.x = x; - this.y = y; - } - - void move(int x1, int y1) { - x += x1; - y += y1; - } - - public String toString() { - return "(" + x + ", " + y + ")"; - } - } - - public static void main(String[] args) { - // TODO: Senthil Kumaran decouple Point - Point p1 = new Point(10, 20); - System.out.println("p1 is " + p1); - Point p2 = p1; - p2.move(8, 8); - System.out.println("p2 is " + p2); - System.out.println("p1 is " + p1); - } - -} diff --git a/languages/java/AutoBoxingUnboxing.java b/languages/java/AutoBoxingUnboxing.java deleted file mode 100644 index 487a37e3..00000000 --- a/languages/java/AutoBoxingUnboxing.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Example 3 Automatic Boxing and Unboxing - */ -class AutoBoxingUnboxing { - - public static void main(String[] args) { - Boolean bb1 = false, bb2 = !bb1; // Boxing to false, true - Integer bi1 = 117; - Double bd1 = 1.2; - boolean b1 = bb1; - if (bb1) - System.out.println("Not true"); - int i1 = bi1 + 2; - // short s = bi1; - long l = bi1; - Integer bi2 = bi1 + 2; - Integer[] biarr = {2, 3, 5, 7, 11}; - int sum = 0; - for(Integer bi: biarr) - sum += bi; - for(int i: biarr) - sum += i; - int i = 1934; - Integer bi4 = i, bi5 = i; - - // Prints true true true flase; bi4 == bi5 is a reference comparison - System.out.format("%b %b %b %b\n", i==i, bi4==i, i==bi5, bi4==bi5); - Boolean bbn = null; - // boolean b = bbn; // compiles Okay but will fail at runtime - // if (bbn) - // System.out.println("Not True"); - Integer bin = null; - // Integer bi6 = bin + 2; // compiles Okay, but will fail at runtime - } -} diff --git a/languages/java/BinaryOutput.java b/languages/java/BinaryOutput.java deleted file mode 100644 index 5d5b3166..00000000 --- a/languages/java/BinaryOutput.java +++ /dev/null @@ -1,60 +0,0 @@ -import java.io.*; - -/** - * Example 147 - Binary Input and Output of Primitive Data - */ -class BinaryOutput { - - public static void main(String[] args) throws IOException { - DataOutputStream daos = new DataOutputStream(new FileOutputStream("tmp1.dat")); - writedata(daos); - daos.close(); - - DataInputStream dais = new DataInputStream(new FileInputStream("tmp1.dat")); - readdata(dais); - - RandomAccessFile raf = new RandomAccessFile("tmp2.dat", "rw"); - writedata(raf); - raf.seek(0); - readdata(raf); - } - - static void writedata(DataOutput out) throws IOException { - out.writeBoolean(true); - out.writeByte(120); - out.writeBytes("foo"); - out.writeBytes("fo"); - out.writeChar('A'); - out.writeChars("foo"); - out.writeDouble(300.1); - out.writeFloat(300.2F); - out.writeInt(1234); - out.writeLong(12345L); - out.writeShort(32000); - out.writeUTF("foo"); - out.writeByte(-1); - out.writeShort(-1); - } - - static void readdata(DataInput in) throws IOException { - byte[] buf1 = new byte[3]; - System.out.print(in.readBoolean()); - System.out.print(" " + in.readByte()); - in.readFully(buf1); - in.readFully(buf1, 0, 2); - System.out.print(" " + in.readChar()); - System.out.print(" " + in.readChar() + in.readChar() + in.readChar()); - System.out.print(" " + in.readDouble()); - System.out.print(" " + in.readFloat()); - System.out.print(" " + in.readInt()); - System.out.print(" " + in.readLong()); - System.out.print(" " + in.readShort()); - System.out.print(" " + in.readUTF()); - System.out.print(" " + in.readUTF()); - System.out.print(" " + in.readUnsignedByte()); - System.out.print(" " + in.readUnsignedShort()); - System.out.println(); - } - - -} diff --git a/languages/java/BinarySearchSortedArray.java b/languages/java/BinarySearchSortedArray.java deleted file mode 100644 index 965283fd..00000000 --- a/languages/java/BinarySearchSortedArray.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Example 73 - Binary Search of a Sorted Array using a While loop - */ -public class BinarySearchSortedArray { - - public static int binarySearch(double[] arr, double x) { - int a = 0, b = arr.length - 1; - - while (a <= b) { // Loop invariant: arr[a-1] < x < arr[b+1] - int i = (a + b) / 2; - if (arr[i] < x) - a = i + 1; - else if (arr[i] > x) - b = i - 1; - else - return i; // because arr[i] == x - } - // Now a > b, in fact a = b+1 and b = a -1, and so arr[b] < x < arr[a] - // TODO: Senthil Kumaran - Why ~a ? - // return ~a; - return -1; - } - - public static void main(String[] args) { - double[] arr = { 4, 5, 6, 7, 8, 10, 12, 14}; - System.out.println(binarySearch(arr, 6.0)); - System.out.println(binarySearch(arr, 9.0)); - } -} diff --git a/languages/java/BitwiseOperators.java b/languages/java/BitwiseOperators.java deleted file mode 100644 index 72749205..00000000 --- a/languages/java/BitwiseOperators.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Example 47 - Bitwise Operators and Shift Operators - */ -public class BitwiseOperators { - - static void println4(int n) { - for (int i = 3; i >=0 ; i--) { - System.out.println(n>>i & 1); - } - System.out.println(); - } - - public static void main(String[] args) throws Exception { - int a = 0x3; - int b = 0x5; - println4(a); - println4(b); - println4(~a); - println4(~b); - println4(a & b); - println4(a ^ b); - println4(a | b); - } -} diff --git a/languages/java/BlockStatements.java b/languages/java/BlockStatements.java deleted file mode 100644 index 88228f23..00000000 --- a/languages/java/BlockStatements.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Example 61 - Block Statements - */ -public class BlockStatements { - - public static void main(String[] args) { - int offset = 10; - - class Pair { - public final int fst, snd; - - Pair(int fst, int snd) { - this.fst = fst; - this.snd = snd; - } - - public String toString() { - return String.format("(%d, %d)", fst, snd); - } - } - - { - Pair p1 = new Pair(10, 10+offset); - System.out.println(p1); - } - - { - Pair p1 = new Pair(200, 300); - System.out.println(p1); - } - - } -} diff --git a/languages/java/BuildingConcordance.java b/languages/java/BuildingConcordance.java deleted file mode 100644 index e8a752fc..00000000 --- a/languages/java/BuildingConcordance.java +++ /dev/null @@ -1,49 +0,0 @@ -import java.io.*; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; - -/** - * Example 127 Building a Concordance - */ -class BuildingConcordance { - - static SortedMap> buildIndex(String filename) throws IOException { - - Reader r = new BufferedReader(new FileReader(filename)); - StreamTokenizer stok = new StreamTokenizer(r); - stok.quoteChar('"'); - stok.ordinaryChars('!', '/'); - stok.nextToken(); - - SortedMap> index = new TreeMap>(); - - while (stok.ttype != StreamTokenizer.TT_EOF) { - if (stok.ttype == StreamTokenizer.TT_WORD) { - SortedSet ts; - if (index.containsKey(stok.sval)) - ts = index.get(stok.sval); - else { - ts = new TreeSet(); - index.put(stok.sval, ts); - } - ts.add(stok.lineno()); - } - stok.nextToken(); - } - return index; - } - - - public static void main(String[] args) { - try { - SortedMap> concord = buildIndex("WeekdayNametoNumberHashMap.java"); - - for(String word: concord.keySet()) - System.out.println(word + concord.get(word).toString()); - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/languages/java/CallingNonOverloaded.java b/languages/java/CallingNonOverloaded.java deleted file mode 100644 index 232f36ab..00000000 --- a/languages/java/CallingNonOverloaded.java +++ /dev/null @@ -1,60 +0,0 @@ -import java.util.ArrayList; - -/** - * Example 56 - Calling Non Overloaded, Non Overridden Methods - */ -class CallingNonOverloaded { - - static class SPoint { - static ArrayList allpoints = new ArrayList(); - int x, y; - - SPoint(int x, int y) { - allpoints.add(this); - this.x = x; - this.y = y; - } - - void move(int dx, int dy) { - x += dx; - y += dy; - } - - public String toString() { - return "(" + x + ", " + y + ")"; - } - - int getIndex() { - return allpoints.indexOf(this); - } - - static int getSize() { - return allpoints.size(); - } - - static SPoint getPoint(int i) { - return allpoints.get(i); - } - - } - - public static void main(String[] args) { - System.out.println("Number of points created: " + SPoint.getSize()); - SPoint p = new SPoint(12, 123); - SPoint q = new SPoint(200, 10); - SPoint r = new SPoint(99, 12); - SPoint s = p; - - // Interesting - q = null; - - System.out.println("Number of points created: " + SPoint.getSize()); - // Bad Style - System.out.println("Number of points created: " + q.getSize()); - System.out.println("r is point number" + r.getIndex()); - for (int i = 0; i < SPoint.getSize(); i++) - System.out.println("SPoint number " + i + " is " + SPoint.getPoint(i)); - } - - -} diff --git a/languages/java/CallingOverloaded.java b/languages/java/CallingOverloaded.java deleted file mode 100644 index 5bc8639e..00000000 --- a/languages/java/CallingOverloaded.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Example 58 - Calling Overloaded Methods - */ -class CallingOverloaded { - static class Access { - private static int x; - static class SI { - private static int y = x; // Access private x from enclosing class - } - - static void m() { - int z = SI.y; // Access private y from nested class - } - - double m(int i) { - return i; - } - boolean m(boolean b) { - return !b; - } - - static double m(int x, int y) { - return x + y + 1; - } - - static double m(double x, double y) { - return x + y + 3; - } - } - - public static void main(String[] args) { - Access a = new Access(); - System.out.println(Access.m(10, 20)); - System.out.println(Access.m(10, 20.0)); - System.out.println(Access.m(10.0, 20)); - System.out.println(Access.m(10.0, 20.0)); - } - -} diff --git a/languages/java/CallingOverriddenConstructor.java b/languages/java/CallingOverriddenConstructor.java deleted file mode 100644 index 522cb9aa..00000000 --- a/languages/java/CallingOverriddenConstructor.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Example 60 - Calling Overridden Methods from a Constructor - */ - -class D1 { - D1() { - m2(); - } - - void m1() { - System.out.println("D1.m1"); - } - - void m2() { - System.out.println("D1.m2"); - m1(); - } -} - -class D2 extends D1 { - int f; - D2() { - f = 7; - } - - void m1() { - System.out.println("D2.m1: " + f); - } -} - -class CallingOverriddenConstructor { - public static void main(String[] args) { - D2 d2 = new D2(); - D1 d1 = new D1(); - d2.m1(); - d2.m2(); - d1.m1(); - d1.m2(); - } - -} diff --git a/languages/java/CallingOverriden.java b/languages/java/CallingOverriden.java deleted file mode 100644 index 247ba183..00000000 --- a/languages/java/CallingOverriden.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Example 59 - Calling Overridden and Overloaded Methods - */ -class C1 { - static void m1(double d) { - System.out.println("11d"); - } - void m1(int i) { - System.out.println("11i"); - } - void m2(int i) { - System.out.println("12i"); - } -} - -class C2 extends C1 { - static void m1(double d) { - System.out.println("21d"); - } - - void m1(int i) { - System.out.println("21i"); - } - - void m2(double d) { - System.out.println("22d"); - } - - void m2(Integer ii) { - System.out.println("22ii"); - } - - void m3(int i) { - System.out.println("23i"); - } - - void m4(Integer ii) { - System.out.println("24ii"); - } - -} -class CallingOverriden { - - public static void main(String[] args) { - int i = 17; - Integer ii = new Integer(i); - double d = 17.0; - C2 c2 = new C2(); - C1 c1 = c2; - c1.m1(i); c2.m1(i); c1.m1(d); c2.m1(d); - c1.m2(i); - c2.m2(i); - c2.m2(ii); - c2.m3(ii); - c2.m4(i); - } - -} diff --git a/languages/java/ClassesInterfaces.java b/languages/java/ClassesInterfaces.java deleted file mode 100644 index bb48df3c..00000000 --- a/languages/java/ClassesInterfaces.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Example 86 - Classes Implementing Interfaces - */ - -import javax.swing.*; -import java.applet.Applet; -import java.awt.*; - -interface Colored { Color getColor();} -interface Drawable { void draw(Graphics g);} -interface ColoredDrawable extends Colored, Drawable {} - -class ColoredPoint extends Point implements Colored { - Color c; - ColoredPoint(int x, int y, Color c) { - super(x, y); - this.c = c; - } - - @Override - public Color getColor() { - return c; - } -} - -class ColoredDrawablePoint extends ColoredPoint implements ColoredDrawable { - - ColoredDrawablePoint(int x, int y, Color c) { - super(x, y, c); - } - - @Override - public void draw(Graphics g) { - g.fillRect(x, y, 1, 1); - } -} - -class ColoredRectangle implements ColoredDrawable { - int x1, x2, y1, y2; - Color c; - - ColoredRectangle(int x1, int y1, int x2, int y2, Color c) { - this.x1 = x1; - this.y1 = y1; - this.x2 = x2; - this.y2 = y2; - this.c = c; - } - - public Color getColor() { - return c; - } - - public void draw(Graphics g) { - g.drawRect(x1, y1, x2-x1, y2-y1); - } -} - -class ClassesInterfaces extends Applet{ - - public static void main(String[] args) { - JFrame jp1 = new JFrame(); - ColoredRectangle rect = new ColoredRectangle(10, 10, 30, 30, Color.BLACK); - // TODO: Senthil Kumaran - Use Graphics object g. - ClassesInterfaces c = new ClassesInterfaces(); - jp1.getContentPane().add(c, BorderLayout.CENTER); - jp1.setVisible(true); - - } - -} diff --git a/languages/java/Comments.java b/languages/java/Comments.java deleted file mode 100644 index 7d1da2c3..00000000 --- a/languages/java/Comments.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Example 1 - Comments - */ -class Comments { - //This is single line comment - - /* - This is a multi-line comment, which can span across lines. - */ - public static void main(String[] arg) { - int /* The delimited comment can extend over a part of the line */ x = 42; - System.out.printf("%d",x); - } -} diff --git a/languages/java/CompleteInputOutput.java b/languages/java/CompleteInputOutput.java deleted file mode 100644 index 40c0ba00..00000000 --- a/languages/java/CompleteInputOutput.java +++ /dev/null @@ -1,21 +0,0 @@ -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -/** - * Example 140 - A Complete Input-Output Example - */ -class CompleteInputOutput { - - public static void main(String[] args) throws IOException { - BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); - int count = 0; - String s = r.readLine(); - while (s != null & !s.equals("")) { - count++; - s = r.readLine(); - } - System.out.println("You entered " + count + " non empty lines"); - } - -} diff --git a/languages/java/CompoundAssignment.java b/languages/java/CompoundAssignment.java deleted file mode 100644 index 771bbc1d..00000000 --- a/languages/java/CompoundAssignment.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Example 50 - Compound Assignment Operators - */ -class CompoundAssignment { - - static double multiply(double[] xs) { - double prod = 1.0; - for (int i = 0; i < xs.length; i++) { - prod *= xs[i]; - } - return prod; - } - - public static void main(String[] args) { - double[] xs = {1.0, 2.0, 3.0}; - System.out.println(multiply(xs)); - } -} diff --git a/languages/java/ConcatCliArgs.java b/languages/java/ConcatCliArgs.java deleted file mode 100644 index e007a361..00000000 --- a/languages/java/ConcatCliArgs.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Example 100 - Efficiently Concatenating All Command Line Arguments - */ -class ConcatCliArgs { - public static void main(String[] args) { - StringBuilder res = new StringBuilder(); - for (int i = 0; i < args.length; i++) - res.append(args[i]); - System.out.println(res.toString()); - } -} diff --git a/languages/java/Concatenate.java b/languages/java/Concatenate.java deleted file mode 100644 index cd6450b2..00000000 --- a/languages/java/Concatenate.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Example 9 Concatenating all Command Line Arguments. - */ - -class Concatenate { - public static void main(String[] args) { - String res = ""; - for(int i = 0; i < args.length; i++) - res += args[i]; - System.out.println(res); - } -} diff --git a/languages/java/ConcordanceUsingIterables.java b/languages/java/ConcordanceUsingIterables.java deleted file mode 100644 index cac96dcc..00000000 --- a/languages/java/ConcordanceUsingIterables.java +++ /dev/null @@ -1,49 +0,0 @@ -import java.io.*; -import java.util.*; - -/** - * Example 130 - Printing a Concordance Using Iterables - */ -class ConcordanceUsingIterables { - - static SortedMap> buildIndex(String filename) throws IOException { - - Reader r = new BufferedReader(new FileReader(filename)); - StreamTokenizer stok = new StreamTokenizer(r); - stok.quoteChar('"'); - stok.ordinaryChars('!', '/'); - stok.nextToken(); - - SortedMap> index = new TreeMap>(); - - while (stok.ttype != StreamTokenizer.TT_EOF) { - if (stok.ttype == StreamTokenizer.TT_WORD) { - SortedSet ts; - if (index.containsKey(stok.sval)) - ts = index.get(stok.sval); - else { - ts = new TreeSet(); - index.put(stok.sval, ts); - } - ts.add(stok.lineno()); - } - stok.nextToken(); - } - return index; - } - - static void printIndex(SortedMap> index) { - for (Map.Entry> entry: index.entrySet()) { - System.out.print(entry.getKey() + ": "); - SortedSet lineNoSet = entry.getValue(); - for (int lineno: lineNoSet) - System.out.print(lineno + " "); - System.out.println(); - } - } - - public static void main(String[] args) throws IOException { - SortedMap> concord = buildIndex("WeekdayNametoNumberHashMap.java"); - printIndex(concord); - } -} diff --git a/languages/java/ConcreteCollection.java b/languages/java/ConcreteCollection.java deleted file mode 100644 index 4d186e4e..00000000 --- a/languages/java/ConcreteCollection.java +++ /dev/null @@ -1,76 +0,0 @@ -import java.util.*; - -/** - * Example 121 - Using the Concrete Collection and Map Classes - */ - -class ConcreteCollection { - public static void main(String[] args) { - List list1 = new LinkedList(); - list1.add("list"); - list1.add("dup"); - list1.add("x"); - list1.add("dup"); - traverse(list1); - - List list2 = new ArrayList(); - list2.add("list"); - list2.add("dup"); - list2.add("x"); - list2.add("dup"); - traverse(list2); - - Set set1 = new HashSet(); - set1.add("set"); - set1.add("dup"); - set1.add("x"); - set1.add("dup"); - traverse(set1); - - SortedSet set2 = new TreeSet(); - set2.add("set"); - set2.add("dup"); - set2.add("x"); - set2.add("dup"); - traverse(set2); - - LinkedHashSet set3 = new LinkedHashSet(); - set3.add("set"); - set3.add("dup"); - set3.add("x"); - set3.add("dup"); - traverse(set3); - - Map m1 = new HashMap(); - m1.put("map", "J"); - m1.put("dup", "K"); - m1.put("x", "M"); - m1.put("dup", "L"); - traverse(m1.keySet()); - traverse(m1.values()); - - SortedMap m2 = new TreeMap(); - m2.put("map", "J"); - m2.put("dup", "K"); - m2.put("x", "M"); - m2.put("dup", "L"); - traverse(m2.keySet()); - traverse(m2.values()); - - LinkedHashMap m3 = new LinkedHashMap(); - m3.put("map", "J"); - m3.put("dup", "K"); - m3.put("x", "M"); - m3.put("dup", "L"); - traverse(m3.keySet()); - traverse(m3.values()); - - } - - static void traverse(Collection coll) { - for(String elem: coll) - System.out.print(elem + " "); - System.out.println(); - - } -} diff --git a/languages/java/ConditionalExpression.java b/languages/java/ConditionalExpression.java deleted file mode 100644 index e97685aa..00000000 --- a/languages/java/ConditionalExpression.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Example 51 - Conditional Expression - */ -public class ConditionalExpression { - - static double absolute(double x) { - return (x >= 0 ? x : -x); - } - - public static void main(String[] args) { - Double x = 5.12; - System.out.println(absolute(x)); - } - -} diff --git a/languages/java/ConstraintsType.java b/languages/java/ConstraintsType.java deleted file mode 100644 index 947abd1c..00000000 --- a/languages/java/ConstraintsType.java +++ /dev/null @@ -1,36 +0,0 @@ -import java.util.Date; - -/** - * Example 110 - Constraints Involving Type Parameters - */ - -class ComparablePair, U extends Comparable> - implements Comparable> - { - - public final T fst; - public final U snd; - - public ComparablePair(T fst, U snd) { - this.fst = fst; - this.snd = snd; - } - - @Override - public int compareTo(ComparablePair that) { - int firstCmp = this.fst.compareTo(that.fst); - return firstCmp != 0 ? firstCmp : this.snd.compareTo(that.snd); - } - } -class ConstraintsType { - - public static void main(String[] args) { - Date d = new Date(10); - String s = "Senthil"; - ComparablePair p1 = new ComparablePair(s, d); - ComparablePair p2 = new ComparablePair("Kumaran", new Date(11)); - ComparablePair p3 = new ComparablePair(s, d); - System.out.println(p1.compareTo(p2)); - System.out.println(p1.compareTo(p3)); - } -} diff --git a/languages/java/ConstructorOverloading.java b/languages/java/ConstructorOverloading.java deleted file mode 100644 index 5d768dc5..00000000 --- a/languages/java/ConstructorOverloading.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Example 36 - Constructor Overloading; Calling Another Constructor - */ -class ConstructorOverloading { - int x, y; - - ConstructorOverloading(int x, int y) { - this.x = x; - this.y = y; - } - - ConstructorOverloading(ConstructorOverloading c) { - this(c.x, c.y); - } - - void incr(int x1, int y1) { - x += x1; - y += y1; - } - - public String toString() { - return "(" + x + ", " + y + ")"; - } - - public static void main(String[] args) { - ConstructorOverloading c1 = new ConstructorOverloading(10, 20); - c1.incr(40, 40); - System.out.println(c1); - } -} diff --git a/languages/java/ConversionPrimitive.java b/languages/java/ConversionPrimitive.java deleted file mode 100644 index cd3256d9..00000000 --- a/languages/java/ConversionPrimitive.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Example 4 Conversion between Primitive Types - * - */ -class ConversionPrimitive { - private static void floatdouble(float f, double d) { - System.out.println(f + " " + d); - } - private static void bytecharshort(byte b, char c, short s) { - System.out.println(b + " " + (int) c + " " + s); - } - private static void intint(int i1, int i2) { - System.out.println(i1 + " " + i2); - } - - public static void main(String[] args) { - int i1 = 1000111222, i2 = 40000, i3 = -1; - floatdouble(i1, i1); - bytecharshort((byte)i2, (char)i2, (short)i2); - bytecharshort((byte)i3, (char)i3, (short)i3); - intint((int)1.9, (int)-1.9); - intint((int)1.5, (int)-1.5); - intint((int)2.5, (int)-2.5); - } -} diff --git a/languages/java/CountEs.java b/languages/java/CountEs.java deleted file mode 100644 index cb45c84f..00000000 --- a/languages/java/CountEs.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Example 10 Counting the Number of e's in a String. - */ -class CountEs { - static int ecount(String s) { - int ecount = 0; - for (int i=0; i < s.length(); i++) - if (s.charAt(i) == 'e') - ecount++; - return ecount; - } - - public static void main(String[] args) { - System.out.println(CountEs.ecount("elepantine")); - } -} diff --git a/languages/java/DeclaringCheckedException.java b/languages/java/DeclaringCheckedException.java deleted file mode 100644 index 03323bdf..00000000 --- a/languages/java/DeclaringCheckedException.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Declaring a Checked Exception Class - */ - -class WeekdayException extends Exception { - public WeekdayException(String wday) { - super("Illegal weekday: " + wday); - } -} - -public class DeclaringCheckedException { - - static final String[] wdays = - {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; - - - static int wdayno4(String wday) throws WeekdayException { - for (int i = 0; i < wdays.length; i++) - if (wday.equals(wdays[i])) - return i + 1; - throw new WeekdayException(wday); - } - - public static void main(String[] args) throws WeekdayException { - System.out.println(wdayno4("Monday")); - System.out.println(wdayno4("Sommar")); - } -} diff --git a/languages/java/Describe.java b/languages/java/Describe.java deleted file mode 100644 index 0395b7e3..00000000 --- a/languages/java/Describe.java +++ /dev/null @@ -1,28 +0,0 @@ -public class Describe { - static void describe(Class clazz, String pad, String leadin) { - if (clazz == null) return; - String type = - clazz.isInterface() ? "interface" : - clazz.isArray() ? "array" : - clazz.isPrimitive() ? "primitive" : - clazz.isEnum() ? "enum" : - "class"; - System.out.printf("%s%s%s %s ( %s )%n", - pad, leadin, type, clazz.getSimpleName(), clazz.getName()); - for (Class interfaze : clazz.getInterfaces()) { - describe(interfaze, pad + " ", "implements "); - } - describe(clazz.getComponentType(), pad + " ", "elements are "); - describe(clazz.getSuperclass(), pad + " ", "extends "); -} -static void describe(Class clazz) { - describe(clazz, "", ""); - System.out.println(); -} -public static void main(String[] args) { - describe(boolean[][].class); - describe(java.math.RoundingMode.class); - describe(java.util.ArrayList.class); - describe(void.class); -} -} diff --git a/languages/java/DoWhileRollaDie.java b/languages/java/DoWhileRollaDie.java deleted file mode 100644 index b1066a60..00000000 --- a/languages/java/DoWhileRollaDie.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Example 75 - Using do-while to Roll a Die and Compute Sum Until 5 or 6 Comes up - */ -class DoWhileRollaDie { - - public static void main(String[] args) { - int sum = 0, eyes; - - do { - eyes = (int) (1 + 6 * Math.random()); - sum += eyes; - } while (eyes < 5); - - sum -= eyes; // remove the 5 added. - - System.out.println(sum); - } -} diff --git a/languages/java/EmptyStatement.java b/languages/java/EmptyStatement.java deleted file mode 100644 index 59579e82..00000000 --- a/languages/java/EmptyStatement.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Example 62 - Empty Statement and Infinite Loop Because of misplaced semicolon - */ -public class EmptyStatement { - - public static void main(String[] args) { - - int i = 0; - // misplaced semicolon; runs forver and ever. - while(i < 10); - i++; - } -} diff --git a/languages/java/EnhancedForStatement.java b/languages/java/EnhancedForStatement.java deleted file mode 100644 index 6fdb37ae..00000000 --- a/languages/java/EnhancedForStatement.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Example 69 - Enhanced for statement on an Array - */ -public class EnhancedForStatement { - public static void main(String[] args) { - int[] arr = { 2, 3, 4, 5, 7, 11}; - int sum = 0; - for(int i: arr) - sum += i; - System.out.println(sum); - } -} diff --git a/languages/java/EqualityStrings.java b/languages/java/EqualityStrings.java deleted file mode 100644 index ed4a5831..00000000 --- a/languages/java/EqualityStrings.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Example 7 Equality of Strings and the Subtlety of (+) Operator. - */ -class EqualityStrings { - public static void main(String[] args) { - String s1 = "abc"; - String s2 = s1 + ""; - String s3 = s1; - String s4 = s1.toString(); - - System.out.println("s1 and s2 identical objects: " + (s1 == s2)); - System.out.println("s1 and s3 identical objects: " + (s1 == s3)); - System.out.println("s1 and s4 identical objects: " + (s1 == s4)); - System.out.println("s1 and s2 contain same text: " + (s1.equals(s2))); - System.out.println("s1 and s3 contain same text: " + (s1.equals(s3))); - - System.out.println(10 + 25 + "A"); - System.out.println("A" + 10 + 25); - } -} diff --git a/languages/java/EqualsMethod.java b/languages/java/EqualsMethod.java deleted file mode 100644 index 42859e37..00000000 --- a/languages/java/EqualsMethod.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Example 134 - An equals Method for the Time Class - */ -public class EqualsMethod { - - static class Time implements Comparable