From owner-svn-src-head@freebsd.org Fri Feb 16 16:37:39 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 29491F2321E for ; Fri, 16 Feb 2018 16:37:39 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x22d.google.com (mail-it0-x22d.google.com [IPv6:2607:f8b0:4001:c0b::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AC5A98447C for ; Fri, 16 Feb 2018 16:37:38 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x22d.google.com with SMTP id w63so2432104ita.3 for ; Fri, 16 Feb 2018 08:37:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=IAS4hNilnPgjonYhMZABZ/Bvn369ymYEN3iJhTjkIvA=; b=y4Bn5T1RH2T5HGPLqfEulD3OtDthzOOl81/DQ7YKVQoZtkp0YK+1d6ND9N/Tg/k66s iXiPJ5s2Ql6ukxu2BSvIRa4RxRQDaYn+cZ3DWXR+BhJYaS5aD40VoOGKDunzaX6+v6zj QKh7y5g2PrTZHqGczno0IJ70QS+MZLpvinUn3JPOyd5bJvvdc1i+ZkXkKZeaVCba38YW AY8z1BtyQESqO6lQOnELgVNhs2sd2fN6sY9rnP3bcPC7CAOkUzE28Fd2Np37QGfkjxAp Uc372Z4Kathcbsgikur+6F1u5KL/4nFpc9onxIL1jb6hSXdVexRzukIghRtdYbIsfrq+ /fJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=IAS4hNilnPgjonYhMZABZ/Bvn369ymYEN3iJhTjkIvA=; b=fV+weFgLJPGgVf9mpxFgJlMVyuRuSPJrlJF99Fc+gJKuXH/3dr+G5B4QZZ1WgByq8W XjnerVjInc2rttrQpthYoBy2L21oomN3cQJxISHIRGy+XPItYKFJS+tj8fpy1fB3Vuyz KdsNZkbwSpG+qXdtRNsWG+GIC5eRppUnlGT3PVkVgYr+rVe07OKc9rVZsX+a5WoxsDLx SNJqT/xNwPhheFBaOTwtJ9lwYTynFrElPfJCD1lK0YCuykeywlcgKF3aJrp5Npgs+92N OxcQYnkb+EOdMpApA5yiFX9X4EAAJrI1CiSFs7Bc7ySGM8Rr0983QyKOrw6hdvEx9oJH jXQw== X-Gm-Message-State: APf1xPDaj6ysG4ZBOZ2muTmw/h5e5ZFSURaHhIcDame5Cw9D73tCJtiA 7Yiz7meE9CFJKOLNtvI/dK8+3unTlccPoEXVwCrwQg== X-Google-Smtp-Source: AH8x227btpQZvFvT6spPG1h9AAdhIQRDFFEwhGNnJi61PFnV4htUKx0eMbRjtKF5IfdN/4eBntSqqoNzbwYxdUlON58= X-Received: by 10.36.201.66 with SMTP id h63mr6572248itg.36.1518799057999; Fri, 16 Feb 2018 08:37:37 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.201.67 with HTTP; Fri, 16 Feb 2018 08:37:37 -0800 (PST) X-Originating-IP: [50.253.99.174] In-Reply-To: References: <201802160312.w1G3CO3r085739@repo.freebsd.org> From: Warner Losh Date: Fri, 16 Feb 2018 09:37:37 -0700 X-Google-Sender-Auth: C7x2lwvvtYTVkghKhJLE6gNzFFE Message-ID: Subject: Re: svn commit: r329349 - head/stand/lua To: Kyle Evans Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Feb 2018 16:37:39 -0000 On Feb 16, 2018 6:58 AM, "Kyle Evans" wrote: On Thu, Feb 15, 2018 at 9:12 PM, Kyle Evans wrote: > Author: kevans > Date: Fri Feb 16 03:12:24 2018 > New Revision: 329349 > URL: https://svnweb.freebsd.org/changeset/base/329349 > > Log: > stand/lua: Reduce magic numbers > > Enter/backspace values are hardcoded in both the menu and password scripts. > Separate these out to core for reuse between the two. > > Modified: > head/stand/lua/core.lua > head/stand/lua/menu.lua > head/stand/lua/password.lua > > Modified: head/stand/lua/core.lua > ============================================================ ================== > --- head/stand/lua/core.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/core.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -28,6 +28,10 @@ > > local core = {}; > > +-- Commonly appearing constants > +core.KEY_ENTER = 13 > +core.KEY_BACKSPACE = 127 > + > function core.setVerbose(b) > if (b == nil) then > b = not core.verbose; > > Modified: head/stand/lua/menu.lua > ============================================================ ================== > --- head/stand/lua/menu.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/menu.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -273,9 +273,9 @@ function menu.run(m) > local key = io.getchar(); > > -- Special key behaviors > - if (key == 127) and (m ~= menu.welcome) then > + if (key == core.KEY_BACKSPACE) and (m ~= menu.welcome) then > break > - elseif (key == 13) then > + elseif (key == core.KEY_ENTER) then > core.boot(); > -- Should not return > end > @@ -357,7 +357,7 @@ function menu.autoboot() > screen.defcursor(); > if io.ischar() then > local ch = io.getchar(); > - if ch == 13 then > + if ch == core.KEY_ENTER then > break; > else > -- prevent autoboot when escaping to interpreter > > Modified: head/stand/lua/password.lua > ============================================================ ================== > --- head/stand/lua/password.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/password.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -37,11 +37,11 @@ function password.read() > > repeat > ch = io.getchar(); > - if ch == 13 then > + if ch == core.KEY_ENTER then > break; > end > > - if ch == 8 then > + if ch == core.KEY_BACKSPACE then It's worth noting that this changes the comparison from 'ch == 8' to 'ch == 127'. The password prompt was non-functional on my test systems until this change, because I can never type my password right the first time. =) Pointed out by: cem@ History has shown we likely want to accept both BS (8) and DEL (127) as logical 'backwards erase character' signals. Warner