diff --git a/digressions/Makefile b/digressions/Makefile deleted file mode 100644 index 17f9f0f..0000000 --- a/digressions/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -CFLAGS += -g -Wall -Wextra -pedantic -pedantic-errors - -%.class:%.java - javac -d $(PWD) $^ - -all: temperatures qsort-example getopt-example URLParts.class - -.PHONY: all diff --git a/digressions/URLParts.java b/digressions/URLParts.java deleted file mode 100644 index 09dafff..0000000 --- a/digressions/URLParts.java +++ /dev/null @@ -1,52 +0,0 @@ -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.Collections; - -/** - * A crappy little toy exercise not intended for actual usage. - * Given a URL as first argument, prints the component parts on separate lines - * all fancy-like. Also does some silly guessing when there's no port - * provided. Unmazing. - */ -public class URLParts { - public static final Map defaultPorts; - static { - Map tmpMap = new HashMap(); - tmpMap.put("http", 80); - tmpMap.put("https", 443); - tmpMap.put("file", -1); - defaultPorts = Collections.unmodifiableMap(tmpMap); - } - - public static void main(String[] args) throws Exception { - for (int i = 0; i < args.length; i++) { - showParts(new URL(args[i])); - } - } - - public static void showParts(URL url) { - String protocol = url.getProtocol(); - int port = url.getPort(); - if (port == -1) { - port = getDefaultPortForProtocol(protocol); - } - - showPart("protocol", protocol); - showPart("host", url.getHost()); - showPart("port", Integer.toString(port)); - } - - public static void showPart(String name, String value) { - System.out.println(String.format("%s: %s", name, value)); - } - - public static int getDefaultPortForProtocol(String protocol) { - if (protocol == null) { - protocol = "http"; - } else { - protocol = protocol.toLowerCase(); - } - return defaultPorts.get(protocol); - } -} diff --git a/digressions/.gitignore b/gnu-c/.gitignore similarity index 100% rename from digressions/.gitignore rename to gnu-c/.gitignore diff --git a/gnu-c/Makefile b/gnu-c/Makefile new file mode 100644 index 0000000..1472bc8 --- /dev/null +++ b/gnu-c/Makefile @@ -0,0 +1,6 @@ +TARGETS := $(patsubst %.c,%,$(wildcard *.c)) +CFLAGS += -g -Wall -Wextra -pedantic -pedantic-errors + +all: $(TARGETS) + +.PHONY: all diff --git a/digressions/getopt-example.c b/gnu-c/getopt-example.c similarity index 100% rename from digressions/getopt-example.c rename to gnu-c/getopt-example.c diff --git a/digressions/qsort-example.c b/gnu-c/qsort-example.c similarity index 100% rename from digressions/qsort-example.c rename to gnu-c/qsort-example.c diff --git a/digressions/temperatures.c b/gnu-c/temperatures.c similarity index 100% rename from digressions/temperatures.c rename to gnu-c/temperatures.c